using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Reflection; using System.IO; using System.Runtime.Serialization.Formatters.Binary; using System.Data.SqlClient; using System.Data.Common; using DevExpress.XtraEditors; using CommonLib.utils; using CommonLib; using Lskj.Common; using Lskj.MyControl; using CommonLib.data; using DevExpress.Utils; using DevExpress.XtraTab; using System.Collections; using DevExpress.XtraBars; using Lskj.PubUtils; namespace Lskj.BaseInfo { public partial class FrmMain : FormBase { #region 公用属性 public string IsView { get; set; } public string ObjectId { get; set; } #endregion #region 私有属性 /// /// 加载表单key /// private string Formkey = string.Empty; /// /// 查询分类Sql /// private string fieldsql = string.Empty; /// /// 操作表名 /// private string TableName = string.Empty; /// /// 上传附件目录Id /// private int dirid = 0; /// /// 主键名称 /// private string FiledNameKey = string.Empty; /// /// 操作字段 /// private DataTable dtFileds; public string BackSelected; public string column_prefix = string.Empty; private Font _font = new Font("宋体", 20, FontStyle.Bold); private Brush _brush = new SolidBrush(Color.Red); private Pen _pen = new Pen(Color.Red, 2f); private float _angle = -20f; private string _text = "已审核"; private string basePrintType, baseModuleFile, basePrintSQL, basePrintSQL1, basePrintSQL2; private string printAddCond; #endregion private string AuditAdvice = string.Empty; #region 构造函数 public FrmMain() { //DevExpress.Skins.SkinManager.EnableFormSkins(); //DevExpress.XtraGrid.Localization.GridResLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraGridCHS(); //DevExpress.XtraEditors.Controls.Localizer.Active = new Dxper.LocalizationCHS.Win.XtraEditorsCHS(); //DevExpress.XtraLayout.Localization.LayoutLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraLayoutCHS(); //DevExpress.XtraPrinting.Localization.PreviewLocalizer.Active = new Dxper.LocalizationCHS.Win.XtraPrintingCHS(); InitializeComponent(); } #endregion #region 初始化数据 /// /// 初始化数据 /// /// protected override void OnLoad(EventArgs e) { if (!string.IsNullOrEmpty(FormText)) { this.Text = this.Text + "-[" + FormText + "]"; } DLLCoid = string.IsNullOrEmpty(ModuleId) ? DLLCoid : ModuleId; string tmpSql = "select stepName,stepApplyText from P_systemdlltabflow where typeCode='" + DLLCoid + "' and stepCode='100'"; DataTable dtInfo = SqlHelper.ExecuteDataSet(tmpSql).Tables[0]; string curstepName = string.Empty; string stepApplyText = "审核"; if ((dtInfo != null) && (dtInfo.Rows.Count > 0)) { curstepName = "—" + dtInfo.Rows[0]["stepName"].ToString(); stepApplyText = dtInfo.Rows[0]["stepApplyText"].ToString(); } this.Text = FormText + curstepName + " [数据标识:" + ObjectId + "]"; gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center; DataTable dtSystemdlltab = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemdlltab where DLLCoid='{0}'", DLLCoid)).Tables[0]; if (dtSystemdlltab.Rows.Count > 0) Formkey = dtSystemdlltab.Rows[0]["formKey"] + ""; if (string.IsNullOrEmpty(Formkey)) { PubUtil.WriteLog("模块配置不正确", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (dtSystemdlltab.Columns.Contains("backSelected")) { BackSelected = dtSystemdlltab.Rows[0]["backSelected"] + ""; } this.Text = FormText; dtFileds = SqlHelper.ExecuteDataSet(string.Format("select * from v_systemcontrolLocation where formKey='{0}' order by orderid asc", Formkey)).Tables[0]; int parentHeight = 0; int parentWidth = 0; DataTable dtParentControl = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemControlParent where formKey='{0}'", Formkey)).Tables[0]; if (dtParentControl.Rows.Count > 0) { parentHeight = Convert.ToInt32(dtParentControl.Rows[0]["parentHeight"]); parentWidth = Convert.ToInt32(dtParentControl.Rows[0]["parentWidth"]); this.Height = parentHeight + 130; } if (parentHeight > 0) { plMain.Height = parentHeight; } if (parentWidth > 0) { this.Width = parentWidth + 242; } DataRow row_systemwordbook_key = SqlHelper.ExecuteDataSet("select * from P_systemwordbooktab where tab='" + DLLCoid + "' and orderid=1").Tables[0].Rows[0]; DataRow row_systemDll = SqlHelper.ExecuteDataSet("select * from P_systemDlltab where DLLCoid='" + DLLCoid + "'").Tables[0].Rows[0]; DataTable dtTag3 = SqlHelper.ExecuteDataSet("select * from P_systemwordbooktab where tab='" + DLLCoid + "' and fieldsqlTag=3").Tables[0]; //打印 if (row_systemDll.Table.Columns.Contains("printType")) basePrintType = row_systemDll["printType"] + ""; if (row_systemDll.Table.Columns.Contains("baseModuleFile")) baseModuleFile = row_systemDll["baseModuleFile"] + ""; if (row_systemDll.Table.Columns.Contains("basePrintSQL")) basePrintSQL = row_systemDll["basePrintSQL"] + ""; if (row_systemDll.Table.Columns.Contains("basePrintSQL1")) basePrintSQL1 = row_systemDll["basePrintSQL1"] + ""; if (row_systemDll.Table.Columns.Contains("basePrintSQL2")) basePrintSQL2 = row_systemDll["basePrintSQL2"] + ""; if (row_systemDll.Table.Columns.Contains("printAddCond")) printAddCond = row_systemDll["printAddCond"] + ""; TableName = row_systemDll["SQLDT1"] + ""; column_prefix = PubClass.GetColumnPrefix(TableName); dirid = Convert.ToInt32(row_systemDll["dirid"]); FiledNameKey = row_systemwordbook_key["fieldname"] + ""; DataTable dt = SqlHelper.ExecuteDataSet("select * from " + TableName + " where " + FiledNameKey + "='" + ObjectId + "'").Tables[0]; if (dtTag3 != null && dtTag3.Rows.Count > 0) { fieldsql = dtTag3.Rows[0]["fieldsql"] + ""; fieldsql = PubClass.ReqSqlParam(fieldsql, OperatorId, OperatorName); fieldsql = "select * from (" + fieldsql + ") xx "; #region 替换{##}默认值参数 string fieldTagName = dtTag3.Rows[0]["fieldName"] + ""; string fieldTagValue = dt.Rows[0][fieldTagName] + ""; if (!string.IsNullOrEmpty(fieldTagName) && !string.IsNullOrEmpty(fieldTagValue)) { DataTable dtTagTable = SqlHelper.ExecuteDataSet(string.Format(fieldsql + " WHERE {0}='{1}'", fieldTagName, fieldTagValue)).Tables[0]; foreach (DataRow row in dtFileds.Rows) { string dValue = row["defaultValue"] + ""; if (!string.IsNullOrEmpty(dValue) && dValue.Contains("{##")) { List list = PubClass.GetParamValue(dValue); for (int i = 0; i < list.Count; i++) { if (list[i].Contains("##")) { string fileName = list[i].Replace("##", "").Replace("{", "").Replace("}", ""); if (dtTagTable.Columns[fileName] != null && dtTagTable.Rows.Count == 1) { dValue = dValue.Replace(list[i], dtTagTable.Rows[0][fileName] + ""); } } } if (list.Count > 0) row["defaultValue"] = dValue; } } } #endregion } CreateControlModel ccm = new CreateControlModel(plMain, "", OperatorId, OperatorName, dtFileds); MyCreateControl createCtr = new MyCreateControl(); createCtr.ParentCtr = plMain; createCtr.LoginId = OperatorId; createCtr.LoginName = OperatorName; if (!string.IsNullOrEmpty(ObjectId)) { if (dt != null && dt.Rows.Count > 0) { createCtr.CreateControlByModel(ccm); MyControlText myctext = new MyControlText(); myctext.dr = dt.Rows[0]; myctext.dt = dtFileds; myctext.ctr = this; createCtr.SetControlText(myctext); } } else { createCtr.CreateControlByModel(ccm); } BindCheckList(); BindTab(); InitPMenu(); string addgroup_sql = String.Format("select * from p_systemaddgroup where formkey='{0}'", Formkey); DataTable dtGroup = SqlHelper.ExecuteDataSet(addgroup_sql).Tables[0]; foreach (DataRow row in dtGroup.Rows) { GroupBox gb = new GroupBox(); gb.Text = row["groupName"] + ""; gb.Width = Convert.ToInt32(row["controlWidth"]); gb.Left = Convert.ToInt32(row["controlLeft"]); gb.Top = Convert.ToInt32(row["controlTop"]); gb.Height = Convert.ToInt32(row["controlHeight"]); plMain.Controls.Add(gb); gb.SendToBack(); } this.CenterToScreen(); } #endregion #region 绑定多标签 public void BindTab() { string tabSql = "select * from p_systembillauditAttach where typeCode='" + DLLCoid + "' and isnull(isVisible,0)=0 order by orderid"; DataTable dtTab = SqlHelper.ExecuteDataSet(tabSql).Tables[0]; tabMain.TabPages.Clear(); foreach (DataRow row in dtTab.Rows) { XtraTabPage tabPage = new XtraTabPage(); tabPage.Text = row["attachName"].ToString(); Panel_GridPage panel_GridPage = new Panel_GridPage(); tabPage.Controls.Add(panel_GridPage); panel_GridPage.Dock = DockStyle.Fill; panel_GridPage.BringToFront(); panel_GridPage.formKey = row["formKey"] + ""; panel_GridPage.DLLCoid = DLLCoid; String newSql = PubClass.ReqSql(plMain, row["attachSql"] + ""); panel_GridPage.gridList.Sql = newSql; tabMain.TabPages.Add(tabPage); } //tab高度 if (dtTab != null && dtTab.Rows.Count > 0) { if (plMain.Height < 350) { plMain.Height = 350; } this.Height = plMain.Height + 300; pl_tab.Visible = true; } else { if (plMain.Height > 600) { this.Height = plMain.Height; } pl_tab.Visible = false; } } #endregion #region 初始化打印 /// /// 初始打印 /// public void InitPrintMenu() { if (!string.IsNullOrEmpty(baseModuleFile)) { String[] strs = baseModuleFile.Split('|'); for (int i = 0; i < strs.Length; i++) { BarButtonItem bbi = new BarButtonItem(); int index = i + 1; bbi.Caption = strs[i].Replace(".rmf", ""); bbi.Tag = strs[i]; bbi.ItemClick += new ItemClickEventHandler(print_ItemClick); pm_print.AddItem(bbi); } } } private void print_ItemClick(object sender, ItemClickEventArgs e) { string tmpSql = basePrintSQL; string tmpSql1 = basePrintSQL1; string tmpSql2 = basePrintSQL2; string printFile = e.Item.Tag + ""; DataTable dt = SqlHelper.ExecuteDataSet("select * from " + TableName + " where " + FiledNameKey + "='" + ObjectId + "'").Tables[0]; if (dt != null && dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; // 验证是否满足打印条件 if (!string.IsNullOrEmpty(printAddCond)) { string tempCond = PubClass.ReqSqlWhere(row, PubClass.ReqSqlParam(printAddCond, OperatorId, OperatorName)); bool canPrint = Convert.ToBoolean(Evaluator.Eval(tempCond)); if (!canPrint) { XtraMessageBox.Show("不满足打印条件,无法打印."); return; } } DialogResult dr = XtraMessageBox.Show("你确定要保存单据后打印?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { string path = PubUtil.AbsolutelyPath + "lib/P_PubPrint.lsp"; tmpSql = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql, OperatorId, OperatorName)); tmpSql = PubClass.ReqSql(plMain, tmpSql); tmpSql1 = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql1, OperatorId, OperatorName)); tmpSql1 = PubClass.ReqSql(plMain, tmpSql1); tmpSql2 = PubClass.ReqSql(row, PubClass.ReqSqlParam(tmpSql2, OperatorId, OperatorName)); tmpSql2 = PubClass.ReqSql(plMain, tmpSql2); //billPrintSQL = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL, OperatorId, OperatorName)); //billPrintSQL1 = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL1, OperatorId, OperatorName)); //billPrintSQL2 = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL2, OperatorId, OperatorName)); PubUtil.LoadDelphiDll(path, path, printFile, tmpSql, tmpSql1, Convert.ToInt32(basePrintType), tmpSql2); } } else { XtraMessageBox.Show("没有找到要打印数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } #endregion #region 附件管理 private void btnAtt_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(ObjectId)) { MessageBox.Show("物料编码不存在", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string[] str = { FormText, OperatorId, OperatorName, Privilege, DLLCoid, ObjectId, IsView, dirid.ToString(), "" }; IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str); form.SubForm.ShowDialog(); } #endregion #region 退出表单 private void btnClose_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.No; } #endregion #region 初始常用工具 /// /// 初始常用工具 /// public void InitPMenu() { string sql = "select * from p_systempopupmenu where menuType=1 and tab='" + DLLCoid + "' and visible2=0"; DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0]; foreach (DataRow item in dt.Rows) { BarButtonItem bbi = new BarButtonItem(); bbi.Caption = item["menuname"] + ""; bbi.Tag = item; pMenu.AddItem(bbi); bbi.ItemClick += new ItemClickEventHandler(bbi_ItemClick); } if (dt.Rows.Count == 0) { dpbTools.Enabled = false; } } protected void bbi_ItemClick(object sender, ItemClickEventArgs e) { DataRow row = e.Item.Tag as DataRow; int actionType = Convert.ToInt32(row["actiontype"]); string action = row["action"].ToString(); string dllName = row["dllname"].ToString(); string maxWindow = row["maxWindow"] + ""; List valueList = new List(); valueList.Add(row["dllpar1"].ToString()); valueList.Add(row["dllpar2"].ToString()); valueList.Add(row["dllpar3"].ToString()); valueList.Add(row["dllpar4"].ToString()); valueList.Add(row["dllpar5"].ToString()); valueList.Add(row["dllpar6"].ToString()); valueList.Add(row["dllpar7"].ToString()); valueList.Add(row["dllpar8"].ToString()); valueList.Add(row["dllpar9"].ToString()); valueList.Add(row["dllpar10"].ToString()); if (actionType == 2) { #region 打开DLL List paremList = new List(); foreach (string item in valueList) { //解析sql if (item.IndexOf('@') != -1) { string sql = item.Replace("@", ""); List sqlpar = PubClass.GetParamValue(sql); foreach (string s in sqlpar) { string fName = "txt_" + s.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { string ctlValue = PubControl.GetControlText(c[0]); sql = sql.Replace(s, ctlValue + ""); } } string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + ""; paremList.Add(param); } else if (item.IndexOf('{') != -1) { string fName = "txt_" + item.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { string ctlValue = PubControl.GetControlText(c[0]); paremList.Add(ctlValue); } } else { paremList.Add(item); } } if (dllName == "Lskj.PhotoView.dll") { string[] str = { FormText, OperatorId, OperatorName, Privilege, DLLCoid, paremList[0], paremList[1], paremList[2], paremList[3], paremList[4], paremList[5], paremList[6], paremList[7], paremList[8], paremList[9] }; IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str); if (maxWindow == "1") form.SubForm.WindowState = FormWindowState.Maximized; form.SubForm.ShowDialog(); } else if (dllName == "Lskj.Attachment.dll") { string[] str = { FormText, OperatorId, OperatorName, Privilege, DLLCoid, paremList[0], paremList[1], paremList[2], paremList[3], paremList[4], paremList[5], paremList[6], paremList[7], paremList[8], paremList[9] }; IForm form = PubUtil.LoadDllForm2("Lskj.Attachment.dll", str); if (maxWindow == "1") form.SubForm.WindowState = FormWindowState.Maximized; form.SubForm.ShowDialog(); } else { string[] str = { FormText, OperatorId, OperatorName, Privilege, DLLCoid, paremList[0], paremList[1], paremList[2], paremList[3], paremList[4], paremList[5], paremList[6], paremList[7], paremList[8], paremList[9] }; IForm form = PubUtil.LoadDllForm(dllName, str); if (maxWindow == "1") form.SubForm.WindowState = FormWindowState.Maximized; form.SubForm.ShowDialog(); } #endregion } else if (actionType == 1) { #region 执行存储过程 List paremList = new List(); ArrayList sqlParamList = new ArrayList(); foreach (string item in valueList) { //解析sql if (item.IndexOf('@') != -1) { string sql = item.Replace("@", ""); List sqlpar = PubClass.GetParamValue(sql); foreach (string s in sqlpar) { string fName = "txt_" + s.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { sql = sql.Replace(s, c[0].Text + ""); } } string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + ""; paremList.Add(param); } else if (item.IndexOf('{') != -1) { string p = item; List sqlpar = PubClass.GetParamValue(item); foreach (string s in sqlpar) { string filedName = s.Replace("{", "").Replace("}", ""); if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase)) { p = p.Replace(s, OperatorName); } else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase)) { p = p.Replace(s, OperatorId); } else { string fName = "txt_" + s.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { p = p.Replace(s, c[0].Text + ""); } } } paremList.Add(p); } else { paremList.Add(item); } } List paramName = PubClass.GetParamValue(action); string[] paramStr = paramName[0].Replace("{", "").Replace("}", "").Split(','); for (int i = 0; i < paremList.Count; i++) { string item = paremList[i]; if (!string.IsNullOrEmpty(item)) { string paramStr1 = paramStr[i]; SqlParameter param = new SqlParameter(string.Format("{0}", paramStr1), DbTypeConverter.ConvertToSql(FieldType.VarChar)); param.Value = item; sqlParamList.Add(param); } } SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, action.Replace(paramName[0], "").Trim(), (SqlParameter[])sqlParamList.ToArray(typeof(SqlParameter))); XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); #endregion } else if (actionType == 3) { List paremList = new List(); foreach (string item in valueList) { if (item.IndexOf('@') != -1) { //解析sql string sql = item.Replace("@", ""); List sqlpar = PubClass.GetParamValue(sql); foreach (string s in sqlpar) { string fName = "txt_" + s.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { sql = action.Replace(s, c[0].Text); } } string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + ""; paremList.Add(param); } else if (item.IndexOf('{') != -1) { string fName = "txt_" + item.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { paremList.Add(c[0].Text); } } else { paremList.Add(item); } PubUtil.LoadDelphiDll(dllName, paremList[0], paremList[1], paremList[2], paremList[3], Convert.ToInt32(paremList[4]), paremList[5]); } } else { //执行SQL #region 执行SQL语句 List pList = PubClass.GetParamValue(action); foreach (string item in pList) { string fName = "txt_" + item.Replace("{", "").Replace("}", ""); Control[] c = plMain.Controls.Find(fName, true); if (c.Length > 0) { action = action.Replace(item, c[0].Text); } } string newSql = action.Replace("{", "@").Replace("}", "").Replace("'", ""); ArrayList parameters = new ArrayList(); for (int i = 0; i < pList.Count; i++) { string filedName = pList[i].Replace("{", "").Replace("}", ""); if (filedName.Equals("loginname", StringComparison.OrdinalIgnoreCase)) { SqlParameter param = new SqlParameter(string.Format("{0}", filedName), DbTypeConverter.ConvertToSql(FieldType.VarChar)); param.IsNullable = true; param.Value = OperatorName; parameters.Add(param); } else if (filedName.Equals("loginid", StringComparison.OrdinalIgnoreCase)) { SqlParameter param = new SqlParameter(string.Format("{0}", filedName), DbTypeConverter.ConvertToSql(FieldType.VarChar)); param.IsNullable = true; param.Value = OperatorId; parameters.Add(param); } else { SqlParameter param = new SqlParameter(string.Format("{0}", filedName), DbTypeConverter.ConvertToSql(FieldType.VarChar)); param.IsNullable = true; param.Value = row[filedName]; parameters.Add(param); } SqlHelper.ExecuteNonQuery(CommandType.Text, newSql, (SqlParameter[])parameters.ToArray(typeof(SqlParameter))); XtraMessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } #endregion } } #endregion #region 流转记录行颜色 private void gridView1_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e) { if (e.RowHandle >= 0) { DataRow row = gridView1.GetDataRow(e.RowHandle); if (row["sh"] + "" == "审") { e.Appearance.ForeColor = Color.Blue; } } } #endregion /// /// 检查结果 /// public void BindCheckList() { DataTable dt = SqlHelper.ExecuteDataSet("select case when stepcode=0 then stepName else REPLACE(REPLACE(REPLACE(operDirection,'R','退'),'F','审'),'Q','关闭') end as sh,* from p_baseflowstep where flowSourceKey='" + ObjectId + "' order by id asc").Tables[0]; gcAttach.DataSource = dt; } private void OnMyPaint(PaintEventArgs e, Control ctl) { base.OnPaint(e); if ((_text == "")) return; GraphicsText graphicsText = new GraphicsText(); graphicsText.Graphics = e.Graphics; // 绘制围绕点旋转的文本 int width = 90; int height = 32; StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; graphicsText.DrawString(_text, _font, _brush, new PointF((ctl.Width - width) / 2, (ctl.Height - height) / 2), format, _angle); int x = (ctl.Width - width) / 2; int y = (ctl.Height - height) / 2; e.Graphics.TranslateTransform(x, y); e.Graphics.RotateTransform(_angle); e.Graphics.DrawRectangle(_pen, new Rectangle(0 - width / 2, 0 - height / 2 - 3, width, height)); } private void gridBillInfo_Paint(object sender, PaintEventArgs e) { OnMyPaint(e, sender as Control); } #region 单据状态 private void SetBillStatus(DataRow datarow) { //MessageBox.Show(datarow["stepover"].ToString()+""); if ((datarow.Table.Columns.Contains(column_prefix + "cancelflag")) && ((datarow[column_prefix + "cancelflag"] + "" == "1") || ((datarow[column_prefix + "cancelflag"] + "").ToLower() == "true"))) _text = "已关闭"; else if ((datarow.Table.Columns.Contains(column_prefix + "waste_flag")) && ((datarow[column_prefix + "waste_flag"] + "" == "1") || ((datarow[column_prefix + "waste_flag"] + "").ToLower() == "true"))) _text = "已作废"; else if ((datarow[column_prefix + "stepover"] + "" == "1") || ((datarow[column_prefix + "stepover"] + "").ToLower() == "true")) _text = "已终审"; else if ((datarow[column_prefix + "ban"] + "" == "1") || ((datarow[column_prefix + "ban"] + "").ToLower() == "true")) _text = "在 审"; else if ((datarow[column_prefix + "affirmer"] + "" != "0") && (datarow[column_prefix + "affirmer"] + "" != "")) _text = "待 审"; else _text = "草 稿"; } #endregion private void gcAttach_Paint(object sender, PaintEventArgs e) { OnMyPaint(e, sender as Control); } /// /// 反审 /// /// /// private void btnReturn_Click(object sender, EventArgs e) { DataTable dt = SqlHelper.ExecuteDataSet("select * from " + TableName + " where " + FiledNameKey + "='" + ObjectId + "'").Tables[0]; if (dt != null && dt.Rows.Count > 0) { DataRow row = dt.Rows[0]; string stepCode = row[column_prefix + "stepCode"] + ""; int ret = ExecuteBackSelect(row); if (ret == -9) return; if (XtraMessageBox.Show("确认审核不通过并反退该单据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { string beforemenuname = string.Empty, beforeusers = string.Empty; int beforeid = 0; try { string sqlValue = string.Format("select operators,ToolsName menuname,'1'+CAST(b.dllid as varchar(10)) id from P_baseflowOper a,P_systemdlltab b where a.modid=b.DllCoid and keyvalue='{0}' and stepcode='{1}' and a.stepover=0", ObjectId, stepCode); DataTable dtTable = SqlHelper.ExecuteDataSet(sqlValue).Tables[0]; if (dtTable.Rows.Count > 0) { beforemenuname = dtTable.Rows[0]["menuname"] + ""; beforeusers = dtTable.Rows[0]["operators"] + ""; beforeid = Convert.ToInt32(dtTable.Rows[0]["id"] + ""); } } catch (Exception) { } SqlParameter msg = new SqlParameter("@msg", SqlDbType.VarChar, 3000); msg.Direction = ParameterDirection.Output; SqlParameter[] param = { new SqlParameter("@typeCode",SqlDbType.VarChar,10), new SqlParameter("@stepCode",SqlDbType.Int,4), new SqlParameter("@billDocumentId",SqlDbType.VarChar,200), new SqlParameter("@operatorId",SqlDbType.Int,4), new SqlParameter("@operatorName",SqlDbType.VarChar,20), new SqlParameter("@auditAdvice",SqlDbType.VarChar,500), new SqlParameter("@Direction",SqlDbType.Char,1), msg, new SqlParameter("@backStepCode",SqlDbType.Int,4) }; param[0].Value = DLLCoid; param[1].Value = stepCode; param[2].Value = ObjectId; param[3].Value = OperatorId; param[4].Value = OperatorName; param[5].Value = ""; param[6].Value = "R"; param[7].Value = ""; param[8].Value = ret; SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_BaseAudit", "bill", param); string result = msg.Value + ""; if (result == "1") { XtraMessageBox.Show("反退成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // 推送消息 PushHelper push = new PushHelper(ObjectId, stepCode, DLLCoid, beforeusers, beforemenuname, beforeid); push.push_base_oper_message(); this.DialogResult = DialogResult.OK; } else { XtraMessageBox.Show("反退失败!" + result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } } private int ExecuteBackSelect(DataRow row) { if (row == null) { MessageBox.Show("没有找到需要反审核的单据"); return -9; } //判断返退选择标记 if (BackSelected == "0") return -1; //第一步直接返退到提交人 if (row[column_prefix + "stepCode"].ToString() == "100") return 0; int billtype = Convert.ToInt32(row[column_prefix + "billtype"].ToString()); frmBackSelect frmSel = new frmBackSelect(DLLCoid, Convert.ToInt32(row[column_prefix + "stepCode"].ToString()), billtype, FiledNameKey, ObjectId, TableName, column_prefix); DialogResult dlg = frmSel.ShowDialog(); if (dlg != DialogResult.OK) return -9; AuditAdvice = frmSel.ComfirmMsg; return frmSel.SelectStepCode; } } }