Files
lserp_cs_5.0/插件库/Lskj.PubAccraditation/Lskj.PubBillAccraditation/FrmAccraditation.cs
T
2026-07-10 15:25:05 +08:00

1597 lines
72 KiB
C#

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.Data.SqlClient;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.Utils;
using DevExpress.XtraTab;
using ControlLib.inh;
using CommonLib;
using Lskj.Common;
using Lskj.MyControl;
using DevExpress.XtraGrid.Columns;
using CommonLib.utils;
using CommonLib.data;
using DevExpress.XtraBars;
using System.Collections;
using Lskj.MyControl.LookUp;
using Lskj.PubUtils;
using DevExpress.XtraEditors.Repository;
using Lskj.MyControl.Panel_Chart;
using System.Text.RegularExpressions;
using Lskj.PubAccraditation.BackSelect;
namespace Lskj.PubBillAccraditation
{
public partial class FrmAccraditation : FormBase
{
string AuditAdvice = string.Empty;
string BackSelected = string.Empty;
#region 属性
/// <summary>
/// 目标打开dll
/// </summary>
public string TargetDLLCoid { get; set; }
/// <summary>
/// 模块名称
/// </summary>
public string FormText { get; set; }
/// <summary>
/// 操作员ID
/// </summary>
public string OperatorId { get; set; }
/// <summary>
/// 操作员名称
/// </summary>
public string OperatorName { get; set; }
/// <summary>
/// 权限名称
/// </summary>
public string Privilege { get; set; }
/// <summary>
/// DLLCoid
/// </summary>
public string DLLCoid { get; set; }
/// <summary>
/// 模块名称
/// </summary>
public string ModuleId { get; set; }
/// <summary>
/// 单据Id
/// </summary>
public string billDocumentId { get; set; }
/// <summary>
/// 流程编码
/// </summary>
public string stepCode { get; set; }
public string OverBacked { get; set; }
private DataRow dtBillInfoRow;
private string column_prefix = string.Empty;
private int mEnterOrder; // 0.默认列跳转,1为行跳转
#endregion
#region 私有属性
/// <summary>
///单据DLLInfo
/// </summary>
private DataTable dtBillInfoFiled { get; set; }
/// <summary>
/// 单据类型model
/// </summary>
private DataRow typeModel { get; set; }
/// <summary>
/// 明细明细列表
/// </summary>
private DataTable attachList;
private DataTable dtType;
private DataTable dtFileds;
private string DirId = string.Empty;
private string Formkey = string.Empty;
//private Dictionary<string, ControlModel> ctrModelList = new Dictionary<string, ControlModel>();
/// <summary>
/// 统计列
/// </summary>
private DataTable dtSum = new DataTable();
private string MasterSql = string.Empty;
private string DetailSql = string.Empty;
private string masterTable = string.Empty;
private string detailTable = string.Empty;
private string billSeq = string.Empty;//单据编号
private string prefix = string.Empty;//单据前缀
private string billModuleFile = string.Empty;
private string billPrintType = string.Empty;
private string billPrintSQL = string.Empty;
private string billPrintSQL1 = string.Empty;
private string billPrintSQL2 = string.Empty;
#endregion
#region 构造函数
public FrmAccraditation()
{
InitializeComponent();
//gridBillInfo.gridView.RowCellClick += new DevExpress.XtraGrid.Views.Grid.RowCellClickEventHandler(gridView_RowCellClick);
gridBillInfo.gridView.SelectionChanged += new DevExpress.Data.SelectionChangedEventHandler(gridBillInfo_SelectionChanged);
//gridBillInfo.gridView.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridView_CellValueChanged);
gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
gridView1.IndicatorWidth = 20;
//gridBillInfo.gridView.KeyDown += new KeyEventHandler(gridBillInfo_KeyDown);
gridBillInfo.gridView.OptionsBehavior.CopyToClipboardWithColumnHeaders = false;
}
#endregion
#region 刷新明细
private void gm_OnGridMenuClickRefreshData(object sender, EventArgs e)
{
string detailSql = DetailSql;
List<String> listParm = PubClass.GetParamValue(detailSql);
foreach (string s in listParm)
detailSql = detailSql.Replace(s, billDocumentId);
gridBillInfo.gridControl.DataSource = SqlHelper.ExecuteDataSet(detailSql).Tables[0];
}
#endregion
#region 初始化数据
protected override void OnLoad(EventArgs e)
{
splitContainerControl1.SplitterPosition = splitContainerControl1.Width - 250;
DLLCoid = TargetDLLCoid;
string tmpSql = "select * from P_systembillflow where typeCode='" + DLLCoid + "' and stepCode='" + stepCode + "'";
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();
btnOk.Text = dtInfo.Rows[0]["stepApplyText"].ToString();
btnReturn.Text = dtInfo.Rows[0]["stepBackText"].ToString();
}
this.Text = FormText + curstepName + " [单据号:" + billDocumentId + "]";
this.btnOk.Text = stepApplyText;
gridView1.Appearance.HeaderPanel.TextOptions.HAlignment = HorzAlignment.Center;
string billInfoSql = "select * from p_systembillinfo where typecode=" + DLLCoid + " and isnull(isvisible,0)=0";
dtBillInfoFiled = SqlHelper.ExecuteDataSet(billInfoSql).Tables[0];
if (dtBillInfoFiled.Columns.Contains("EnterOrder"))
mEnterOrder = string.IsNullOrEmpty(dtBillInfoFiled.Rows[0]["EnterOrder"] + "") ? 0 : Convert.ToInt32(dtBillInfoFiled.Rows[0]["EnterOrder"] + "");
txtCheckName.Text = OperatorName;
txtCheckName.Enabled = false;
txtCheckDate.Enabled = false;
BindCheckList();
BindTab();
BindBill();
string isSumSql = "select * from p_systembillDetail where typeCode=" + DLLCoid + " and isnull(isVisible,0)=0 and isnull(calcExpr,'')<>''order by calcorder asc";
dtSum = SqlHelper.ExecuteDataSet(isSumSql).Tables[0];
gridBillInfo.SumFieldsTable = dtSum;
//单据颜色
string colorSql = "select * from p_systemwordbookcolor where tab='" + "BILLDETAIL_" + Formkey + "'";
DataTable dtColor = SqlHelper.ExecuteDataSet(colorSql).Tables[0];
gridBillInfo.RowColorCondtion = dtColor;
string sql = "select Mix_apellation from P_BaseMixInfoTab a where a.Tag =1201";
txtYj.setDataSource(sql, "Mix_apellation", "Mix_apellation");
txtYj.getComboBox.SelectedValueChanged += new EventHandler(getComboBox_SelectedValueChanged);
txtYj.getComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", gridBillInfo.gridControl);
gm.DirId = DirId;
gm.MainPanel = pl_right_main;
gm.ShowMenuType = "sh";
gm.BindGridMenu("BILLDETAIL_" + DLLCoid);
gm.OnGridMenuClickRefreshData += new EventHandler(gm_OnGridMenuClickRefreshData);
InitPMenu();
txt_Billdocument_Id.Text = billDocumentId;
if (OverBacked == "1")
{
panel1.Visible = false;
}
this.txtCheckDate.Text = DateTime.Now.ToString();
}
protected void getComboBox_SelectedValueChanged(object sender, EventArgs e)
{
txtRemark.Text = txtYj.getComboBox.Text;
}
#endregion
protected void gridView_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
{
}
private void gridBillInfo_SelectionChanged(object sender, DevExpress.Data.SelectionChangedEventArgs e)
{
//GridView gv = (GridView)sender;
//int[] rows = gv.GetSelectedRows();
//if (rows.Length < 1)
// return;
//DataRow row = gv.GetDataRow(rows[0]);
//foreach (DataRow item in attachList.Rows)
//{
// GridControlEx gce = this.Controls.Find("gce_" + item["id"], true)[0] as GridControlEx;
// string sql = gce.Sql;
// List<string> param = PubClass.GetParamValue(gce.Sql);
// foreach (string s in param)
// {
// string filedName = s.Replace("{", "").Replace("}", "");
// sql = sql.Replace(s, row[filedName].ToString());
// }
// gce.ConstSql = sql;
// gce.SetDataSource(sql);
//}
GridView gv = (GridView)sender;
int[] rows = gv.GetSelectedRows();
if (rows.Length < 1)
return;
DataRow row = gv.GetDataRow(rows[0]);
foreach (DataRow item in attachList.Rows)
{
Control[] ctr = this.Controls.Find("gce_" + item["id"], true);
if ((ctr != null) && (ctr.Length > 0))
{
GridControlEx gce = this.Controls.Find("gce_" + item["id"], true)[0] as GridControlEx;
if (gce != null)
{
string sql = gce.Sql;
List<string> param = PubClass.GetParamValue(gce.Sql);
foreach (string s in param)
{
string filedName = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, row[filedName].ToString());
}
gce.ConstSql = sql;
gce.SetDataSource(sql);
}
}
ctr = this.Controls.Find("chart_" + item["id"], true);
if ((ctr != null) && (ctr.Length > 0))
{
Panel_Chart pc = this.Controls.Find("chart_" + item["id"], true)[0] as Panel_Chart;
if (pc != null)
{
string sql = pc.ConstSQL;
List<string> param = PubClass.GetParamValue(sql);
foreach (string s in param)
{
string filedName = s.Replace("{", "").Replace("}", "");
sql = sql.Replace(s, row[filedName].ToString());
}
pc.SQL = sql;
}
}
}
}
#region 处理Grid计算
private void gridView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
try
{
DataRow gvRow = gridBillInfo.gridView.GetDataRow(e.RowHandle);
var fieldSum = dtSum.Rows.Cast<DataRow>().Where(x => x["calcExpr"].ToString().Contains(e.Column.FieldName));
foreach (DataRow row in fieldSum)
{
string calcExpr = row["calcExpr"].ToString();
if (e.Column.FieldName != row["fieldName"].ToString())
{
List<string> listParam = PubClass.GetParamValue(calcExpr);
foreach (string str in listParam)
{
string filed = str.Replace("{", "").Replace("}", "");
string filedValue = gvRow[filed].ToString();
if (string.IsNullOrEmpty(filedValue))
filedValue = "0";
calcExpr = calcExpr.Replace(str, filedValue + "");
}
calcExpr = calcExpr.Replace("=", "==").Replace("<>", "!=").Replace("and", "&&").Replace("or", "|");
string result = Lskj.Common.Evaluator.Eval(calcExpr).ToString();
gridBillInfo.gridView.SetRowCellValue(e.RowHandle, gridBillInfo.gridView.Columns[row["fieldName"].ToString()], Math.Round(double.Parse(result), 2, MidpointRounding.AwayFromZero));
}
}
}
catch
{
}
}
#endregion
/// <summary>
/// 检查结果
/// </summary>
public void BindCheckList()
{
DataTable dt = SqlHelper.ExecuteDataSet("select REPLACE(REPLACE(operDirection,'R','退'),'F','审') as sh,* from wms_billflowstep where flowSourceKey='" + billDocumentId + "' order by id asc").Tables[0];
gcAttach.DataSource = dt;
string sql = "select stepCode from Wms_BillJoinMainTab where Billdocument_Id='" + DLLCoid + "'";
string sql2 = "select * from p_systembillflow where typeCode='" + DLLCoid + "' and stepCode='" + stepCode + "'";
DataTable dt2 = SqlHelper.ExecuteDataSet(sql2).Tables[0];
if (dt2 != null && dt2.Rows.Count > 0)
{
gbName.Text = dt2.Rows[0]["stepName"].ToString();
txtCheckName.LabelText = dt2.Rows[0]["stepName"].ToString();
}
dtType = SqlHelper.ExecuteDataSet("select * from p_systembilltype where typeCode='" + DLLCoid + "'").Tables[0];
if (dtType != null && dtType.Rows.Count > 0)
{
MasterSql = dtType.Rows[0]["MasterSql"].ToString();
DetailSql = dtType.Rows[0]["DetailSql"].ToString();
prefix = dtType.Rows[0]["prefix"].ToString();
billSeq = dtType.Rows[0]["billSeq"].ToString();
masterTable = dtType.Rows[0]["masterTable"].ToString();
detailTable = dtType.Rows[0]["detailTable"].ToString();
DirId = dtType.Rows[0]["DirId"].ToString();
Formkey = dtType.Rows[0]["Formkey"].ToString();
BackSelected = "0";
if (dtType.Columns.Contains("backSelected"))
BackSelected = dtType.Rows[0]["backSelected"].ToString();
if (BackSelected == "")
BackSelected = "0";
//DataTable dtTable = SqlHelper.ExecuteDataSet("select mastertable from p_systembilltype where typecode='" + DLLCoid + "'").Tables[0];
column_prefix = PubClass.GetColumnPrefix(dtType.Rows[0]["mastertable"].ToString());
}
}
#region 绑定选项卡
/// <summary>
/// 绑定选项卡
/// </summary>
public void BindTab()
{
tabDetailMain.TabPages.Clear();
attachList = SqlHelper.ExecuteDataSet("select * from P_systembillauditAttach where typeCode='" + DLLCoid + "' and stepcode='" + stepCode + "' and isnull(isVisible,0)=0").Tables[0];
if (attachList.Rows.Count == 0)
{
plbillInfo.Height = 0;
plbillInfo.Visible = false;
return;
}
bool hasChart = attachList.Columns.Contains("attachType");
foreach (DataRow row in attachList.Rows)
{
hasChart = attachList.Columns.Contains("attachType");
if (hasChart)
hasChart = (row["attachType"] + "" == "1");
XtraTabPage tabPage = new XtraTabPage();
tabPage.Padding = new System.Windows.Forms.Padding(2);
tabPage.Name = "tab" + row["id"];
tabPage.Text = row["attachName"] + "";
if (!hasChart)
{
tabPage.Tag = row["id"];
GridControlEx gce = new GridControlEx();
DataTable dtColor = SqlHelper.ExecuteDataSet("select * from p_systemwordbookcolor where tab='" + row["formkey"] + "' and isnull(useflag,0)=0 order by orderid").Tables[0];
gce.RowColorCondtion = dtColor;
gce.gridView.RowCellStyle += new RowCellStyleEventHandler(gridView_RowCellStyle);
gce.Name = "gce_" + row["id"];
gce.Dock = DockStyle.Fill;
gce.Sql = row["attachSql"] + "";
string sql = "select * from p_systembillauditAttachDetail where attachId=" + row["id"] + " and isnull(isVisible,0)=0 order by orderid";
gce.FormKey = row["typeCode"] + "_bill_detail" + row["id"] + "";
gce.SetColumns(sql);
GridMenu gm = new GridMenu(FormText, OperatorId, OperatorName, Privilege, DLLCoid, "", gce.gridControl, RefreshBill);
gm.DirId = DirId;
string attachKey = row["formkey"] + "";
gm.BindGridMenu(attachKey);
tabPage.Controls.Add(gce);
}
else
{
tabPage.Tag = "chart";
Panel_Chart panel_ChartPage = new Panel_Chart();
tabPage.Controls.Add(panel_ChartPage);
panel_ChartPage.Dock = DockStyle.Fill;
panel_ChartPage.Name = "chart_" + row["id"];
panel_ChartPage.BringToFront();
panel_ChartPage.FormText = FormText;
panel_ChartPage.formKey = row["formKey"] + "";
panel_ChartPage.DLLCoid = DLLCoid;
panel_ChartPage.OperatorId = OperatorId;
panel_ChartPage.Privilege = Privilege;
panel_ChartPage.OperatorName = OperatorName;
String newSql = row["attachSql"] + "";
newSql = PubClass.ReqSqlParam(newSql, OperatorId, OperatorName);
panel_ChartPage.ConstSQL = newSql;
}
tabDetailMain.TabPages.Add(tabPage);
}
}
#endregion
#region 初始常用工具
/// <summary>
/// 初始常用工具
/// </summary>
public void InitPMenu()
{
string sql = "select * from p_systempopupmenu where menuType=1 and tab='" + DLLCoid + "' and isnull(visible2,0)=0 and isnull(visible,0)=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.Visible = false;
btnAtt.Location = new Point(6, 191);
btnAtt.Width = 226;
}
}
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<string> valueList = new List<string>();
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<string> paremList = new List<string>();
foreach (string item in valueList)
{
//解析sql
if (item.IndexOf('@') != -1)
{
string sql = item.Replace("@", "");
List<string> sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string fName = "txt_" + s.Replace("{", "").Replace("}", "");
Control[] c = pl_right_main.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 = pl_right_main.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[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<string> paremList = new List<string>();
ArrayList sqlParamList = new ArrayList();
foreach (string item in valueList)
{
//解析sql
if (item.IndexOf('@') != -1)
{
string sql = item.Replace("@", "");
List<string> sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string fName = "txt_" + s.Replace("{", "").Replace("}", "");
Control[] c = pl_right_main.Controls.Find(fName, true);
if (c.Length > 0)
{
string sValue = PubControl.GetControlText(c[0]);
sql = sql.Replace(s, sValue);
}
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (item.IndexOf('{') != -1)
{
string p = item;
List<string> 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 = pl_right_main.Controls.Find(fName, true);
if (c.Length > 0)
{
string sValue = PubControl.GetControlText(c[0]);
p = p.Replace(s, sValue);
}
}
}
paremList.Add(p);
}
else
{
paremList.Add(item);
}
}
List<string> 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<string> paremList = new List<string>();
foreach (string item in valueList)
{
if (item.IndexOf('@') != -1)
{
//解析sql
string sql = item.Replace("@", "");
List<string> sqlpar = PubClass.GetParamValue(sql);
foreach (string s in sqlpar)
{
string fName = "txt_" + s.Replace("{", "").Replace("}", "");
Control[] c = pl_right_main.Controls.Find(fName, true);
if (c.Length > 0)
{
string sValue = PubControl.GetControlText(c[0]);
sql = action.Replace(s, sValue);
}
}
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
paremList.Add(param);
}
else if (item.IndexOf('{') != -1)
{
string fName = "txt_" + item.Replace("{", "").Replace("}", "");
Control[] c = pl_right_main.Controls.Find(fName, true);
if (c.Length > 0)
{
string sValue = PubControl.GetControlText(c[0]);
paremList.Add(sValue);
}
}
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<string> pList = PubClass.GetParamValue(action);
foreach (string item in pList)
{
string fName = "txt_" + item.Replace("{", "").Replace("}", "");
Control[] c = pl_right_main.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 改变单元格颜色
/// <summary>
/// 改变单元格颜色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void gridView_RowCellStyle(object sender, RowCellStyleEventArgs e)
{
if (e.RowHandle >= 0)
{
XtraTabPage tagpage = tabDetailMain.SelectedTabPage;
Control[] ctl = tagpage.Controls.Find(tagpage.Name.Replace("tab", "gce_"), true);
if (ctl.Length < 1)
return;
if (ctl[0] == null)
return;
GridControlEx gce = ctl[0] as GridControlEx;
DataRow row = gce.gridView.GetDataRow(e.RowHandle);
//颜色集合
DataTable dt = gce.RowColorCondtion as DataTable;
//选择列
string cond = string.Empty;
string color = string.Empty;
string forecolor = string.Empty;
if (dt != null && dt.Rows.Count > 0)
{
foreach (DataRow dr in dt.Rows)
{
List<string> condition = PubClass.GetParamValue(dr["condition"].ToString());
cond = dr["condition"].ToString();
foreach (string item in condition)
{
string filedName = item.Replace("{", "").Replace("}", "");
cond = cond.Replace(item, row[filedName].ToString());
}
cond = PubClass.SqlToCode(cond);
color = dr["backcolor"] + "";
forecolor = dr["forcecolor"].ToString() + "";
string obj = Lskj.Common.Evaluator.Eval(cond) + "";
if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1)
{
if (!string.IsNullOrEmpty(color))
{
System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(color);
e.Appearance.BackColor = color1;
}
if (!string.IsNullOrEmpty(forecolor))
{
System.Drawing.Color foreColor = System.Drawing.ColorTranslator.FromHtml(forecolor);
e.Appearance.ForeColor = foreColor;
}
}
}
}
//string obj = Evaluator.Eval(cond) + "";
//if (obj.IndexOf("true", StringComparison.OrdinalIgnoreCase) != -1)
//{
// if (!string.IsNullOrEmpty(color))
// {
// System.Drawing.Color color1 = System.Drawing.ColorTranslator.FromHtml(color);
// e.Appearance.BackColor = color1;
// }
// if (!string.IsNullOrEmpty(forecolor))
// {
// System.Drawing.Color foreColor = System.Drawing.ColorTranslator.FromHtml(forecolor);
// e.Appearance.ForeColor = foreColor;
// }
//}
}
}
#endregion
#region 单据管理
/// <summary>
/// 绑定单据
/// </summary>
public void BindBill()
{
//创建单据控件
SqlParameter[] p =
{
new SqlParameter("@formkey",SqlDbType.VarChar,200),
new SqlParameter("@modid",SqlDbType.VarChar,50),
new SqlParameter("@operatorname",SqlDbType.VarChar,50)
};
p[0].Value = Formkey;
p[1].Value = DLLCoid;
p[2].Value = OperatorName;
dtFileds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_getControlLocation", "temp", p).Tables[0];
MyCreateControl myCc = new MyCreateControl();
myCc.LoginId = OperatorId;
myCc.LoginName = OperatorName;
CreateControlModel ccm = new CreateControlModel();
ccm.dt = dtFileds;
ccm.ctr = pl_right_main;
ccm.loginid = OperatorId;
ccm.loginname = OperatorName;
myCc.ParentCtr = pl_right_main;
int height = myCc.CreateControlByModel(ccm);
int parentHeight = height;
DataTable dtParentControl = SqlHelper.ExecuteDataSet(string.Format("select parentHeight from p_systemControlParent where formKey='{0}'", Formkey)).Tables[0];
if (dtParentControl.Rows.Count > 0)
{
parentHeight = Convert.ToInt32(dtParentControl.Rows[0]["parentHeight"]) - 36;
if (parentHeight > height)
parentHeight = height;
}
pl_right_main.Height = parentHeight;
//pl_right_main.Height = height;
string billModifyFields = string.Empty;
DataTable dt = SqlHelper.ExecuteDataSet(string.Format("select billModifyFields,detailModifyFields from p_systembillflow where typecode={0} and stepcode={1}", DLLCoid, stepCode)).Tables[0];
GridColumnCollection gcc = gridBillInfo.gridView.Columns;
if (dt != null && dt.Rows.Count > 0)
{
//设置单据头修改字段
billModifyFields = dt.Rows[0]["billModifyFields"].ToString() + ",";
//设置单据头修改字段结束
string detailModifyFields = dt.Rows[0]["detailModifyFields"] + "";
if (!string.IsNullOrEmpty(detailModifyFields))
{
gridBillInfo.gridView.OptionsBehavior.Editable = detailModifyFields != "";
detailModifyFields = detailModifyFields + ",";
foreach (GridColumn item in gcc)
{
if (detailModifyFields.IndexOf(item.FieldName.ToLower() + ",", StringComparison.OrdinalIgnoreCase) != -1)
{
item.OptionsColumn.AllowEdit = true;
item.OptionsColumn.ReadOnly = false;
}
else
{
item.OptionsColumn.AllowEdit = false;
item.OptionsColumn.ReadOnly = true;
}
}
}
}
//查询修改列
string columsSql = string.Format(@"SELECT A.*, ISNULL(B.ISEDITED, 1) AS isEdited
FROM (SELECT *
FROM P_SYSTEMBILLDETAIL A
WHERE TYPECODE = '{0}'
AND ISNULL(ISVISIBLE, 0) = 0
AND (PRIVILEGEVIEW IS NULL OR EXISTS
(SELECT TOP 1 USERLIST
FROM P_SYSTEMPRIVILEGE
WHERE CHARINDEX(CAST(PRIVTYPEID AS VARCHAR(5)) + ',',
A.PRIVILEGEVIEW + ',') > 0
AND MODID = '{0}'
AND CHARINDEX('{1}' + ',', USERLIST + ',') > 0))) A
LEFT JOIN (SELECT FIELDNAME, 0 AS isEdited
FROM P_SYSTEMBILLDETAIL A
WHERE TYPECODE = '{0}'
AND ISNULL(ISVISIBLE, 0) = 0
AND ISNULL(EDITED, 0) = 0
AND (PRIVILEGEOPER IS NULL OR EXISTS
(SELECT TOP 1 USERLIST
FROM P_SYSTEMPRIVILEGE
WHERE CHARINDEX(CAST(PRIVTYPEID AS VARCHAR(5)) + ',',
A.PRIVILEGEOPER + ',') > 0
AND MODID = '{0}'
AND CHARINDEX('{1}' + ',', USERLIST + ',') > 0))) B ON A.FIELDNAME =B.FIELDNAME order by orderid asc", DLLCoid, OperatorName);
gridBillInfo.EnterOrder = mEnterOrder;
gridBillInfo.SetColumns3(columsSql);
gridBillInfo.gridView.OptionsBehavior.Editable = true;
typeModel = SqlHelper.ExecuteDataSet("select * from P_systembilltype where typeCode='" + DLLCoid + "'").Tables[0].Rows[0];
string detailSql = typeModel["detailSql"] + "";
billPrintType = typeModel["billPrintType"].ToString();
billPrintSQL = typeModel["billPrintSQL"].ToString();
billPrintSQL1 = typeModel["billPrintSQL1"].ToString();
billPrintSQL2 = typeModel["billPrintSQL2"].ToString();
billModuleFile = typeModel["billModuleFile"].ToString();
List<String> listParm = PubClass.GetParamValue(typeModel["detailSql"] + "");
foreach (string s in listParm)
detailSql = detailSql.Replace(s, billDocumentId);
gridBillInfo.gridControl.DataSource = SqlHelper.ExecuteDataSet(detailSql).Tables[0];
SetBillControlText(billModifyFields);
initPrint();
}
#region 刷新单据
public void RefreshBill(object sender, string DJH)
{
//typeModel = SqlHelper.ExecuteDataSet("select * from P_systembilltype where typeCode='" + DLLCoid + "'").Tables[0].Rows[0];
int oldRowHandle = -1;
string detailSql = typeModel["detailSql"] + "";
List<String> listParm = PubClass.GetParamValue(typeModel["detailSql"] + "");
foreach (string s in listParm)
detailSql = detailSql.Replace(s, billDocumentId);
oldRowHandle = (gridBillInfo.gridControl.FocusedView as GridView).FocusedRowHandle;
gridBillInfo.gridControl.DataSource = SqlHelper.ExecuteDataSet(detailSql).Tables[0];
(gridBillInfo.gridControl.FocusedView as GridView).FocusedRowHandle = oldRowHandle;
//刷新当前明细
XtraTabPage tagpage = tabDetailMain.SelectedTabPage;
Control[] ctl = tagpage.Controls.Find(tagpage.Name.Replace("tab", "gce_"), true);
if (ctl.Length < 1)
return;
if (ctl[0] == null)
return;
GridControlEx gce = ctl[0] as GridControlEx;
string sql = gce.ConstSql;
oldRowHandle = (gce.gridView as GridView).FocusedRowHandle;
gce.SetDataSource(sql);
(gce.gridView as GridView).FocusedRowHandle = oldRowHandle;
}
#endregion
/// <summary>
/// 查找单据控件
/// </summary>
public void SetBillControlText(string billFields)
{
Control ctr = pl_right_main;
string billInfoSql = PubClass.ReqSqlParam(MasterSql, OperatorId, OperatorName);
List<String> listPar = PubClass.GetParamValue(billInfoSql);
foreach (string item in listPar)
{
billInfoSql = billInfoSql.Replace(item, billDocumentId);
}
DataTable dtBillInfoMsg = SqlHelper.ExecuteDataSet(billInfoSql).Tables[0];
if ((dtBillInfoMsg == null) || (dtBillInfoMsg.Rows.Count < 1))
{
MessageBox.Show("没有找到需要审核的记录");
return;
}
dtBillInfoRow = dtBillInfoMsg.Rows[0];
string rtagid = dtBillInfoMsg.Rows[0][column_prefix + "Rtagid"].ToString();
foreach (DataRow row in dtFileds.Rows)
{
string filedName = "txt_" + row["fieldName"].ToString();
Control[] c = ctr.Controls.Find(filedName, true);
DataColumnCollection dcc = dtBillInfoMsg.Columns;
DataColumn dc = dcc[row["fieldName"].ToString()];
if ((dc != null) && (c != null) && (c.Length > 0))
{
ControlModelTag tagModel = c[0].Tag as ControlModelTag;
if (tagModel.fieldTypeId == 1)
{
LabelComboxEx cb = c[0] as LabelComboxEx;
cb.getComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
cb.getComboBox.SelectedValue = dtBillInfoMsg.Rows[0][row["fieldName"].ToString()].ToString();
//cb.Enabled = false;
}
else if ((tagModel.fieldTypeId == 5) || (tagModel.fieldTypeId == 15))
{
AutoSearcher autos = c[0] as AutoSearcher;
string sql = PubClass.ReqSqlParam("select * from (" + autos.searcherPropertyCollector.QuerySQL + ") tab where " + autos.searcherPropertyCollector.FieldPropertyList[0].FieldName + "='" + dtBillInfoMsg.Rows[0][row["fieldName"].ToString()].ToString() + "'", OperatorId, OperatorName);
sql = Regex.Replace(sql, "#[^##]+#", " 1=1 ");
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
//c[0].Text = dt.Rows[0][autos.searcherPropertyCollector.QueryField].ToString();
//te.SetValueSilent(mctext.dr[row["fieldName"].ToString()].ToString(), "");
autos.SetValueSilent(dt.Rows[0][autos.searcherPropertyCollector.FieldPropertyList[0].FieldName].ToString(), "");
//c[0].Enabled = false;
}
else
{
c[0].Text = string.Empty;
//c[0].Enabled = false;
}
}
else if (tagModel.fieldTypeId == ControlType.LabMultiSelectValue)
{
LabelLookUp lookup = c[0] as LabelLookUp;
lookup.SetValueText(dtBillInfoMsg.Rows[0][row["fieldName"].ToString()].ToString());
}
else
{
c[0].Text = dtBillInfoMsg.Rows[0][row["fieldName"].ToString()].ToString();
//c[0].Enabled = false;
}
//if (billFields.IndexOf(row["fieldName"].ToString() + ",", StringComparison.OrdinalIgnoreCase) != -1)
// c[0].Enabled = true;
int visible = Convert.ToInt32(row["visible"]);
if (visible == 1)
{
c[0].Text = "****";
}
if (billFields.IndexOf(row["fieldName"].ToString() + ",", StringComparison.OrdinalIgnoreCase) != -1)
{
if (c[0] is LabelTextEx)
{
(c[0] as LabelTextEx).GetTextBox.ReadOnly = false;
}
else if (c[0] is LabelAutoSearcherEx)
{
(c[0] as LabelAutoSearcherEx).GetAutoSearcher.ReadOnly = false;
}
else if (c[0] is AutoSearcher)
{
(c[0] as AutoSearcher).ReadOnly = false;
}
else
c[0].Enabled = true;
}
else
{
if (c[0] is LabelTextEx)
{
(c[0] as LabelTextEx).GetTextBox.ReadOnly = true;
}
else if (c[0] is LabelAutoSearcherEx)
{
(c[0] as LabelAutoSearcherEx).GetAutoSearcher.ReadOnly = true;
}
else if (c[0] is AutoSearcher)
{
(c[0] as AutoSearcher).ReadOnly = true;
}
else
c[0].Enabled = false;
}
}
}
}
#endregion
#region 打印相关
private void initPrint()
{
if (!string.IsNullOrEmpty(billModuleFile))
{
//pMprint
String[] strs = billModuleFile.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);
pMprint.AddItem(bbi);
}
}
}
protected void print_ItemClick(object sender, ItemClickEventArgs e)
{
string billNo = txt_Billdocument_Id.Text;
string tmpSQL = "";
string tmpSQL1 = "";
string tmpSQL2 = "";
billModuleFile = e.Item.Tag + "";
if (!string.IsNullOrEmpty(billNo))
{
string sql = PubClass.ReqSqlParam(MasterSql, OperatorId, OperatorName);
List<string> list = PubClass.GetParamValue(sql);
foreach (string str in list)
sql = sql.Replace(str, billNo);
DataTable dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
DataRow row = null;
if (dt != null && dt.Rows.Count > 0)
{
//AddForm(pl_right_main, 2, true);
dt = SqlHelper.ExecuteDataSet(sql).Tables[0];
row = dt.Rows[0];
string path = PubUtil.AbsolutelyPath + "lib/P_PubPrint.lsp";
tmpSQL = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL, OperatorId, OperatorName));
tmpSQL1 = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL1, OperatorId, OperatorName));
tmpSQL2 = PubClass.ReqSql(row, PubClass.ReqSqlParam(billPrintSQL2, OperatorId, OperatorName));
PubUtil.LoadDelphiDll(path, path, billModuleFile, tmpSQL, tmpSQL1, Convert.ToInt32(billPrintType), tmpSQL2);
}
}
}
#endregion
#region 确定审核
/// <summary>
/// 确定审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnOk_Click(object sender, EventArgs e)
{
bool updateOk = UpdateForm();
if (!updateOk)
return;
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,20),
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
};
param[0].Value = DLLCoid;
param[1].Value = stepCode;
param[2].Value = billDocumentId;
param[3].Value = OperatorId;
param[4].Value = OperatorName;
param[5].Value = txtRemark.Text;
param[6].Value = "F";
param[7].Value = "";
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_BillAudit", "bill", param);
string result = msg.Value + "";
if (result == "1")
{
XtraMessageBox.Show("审核成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
this.DialogResult = DialogResult.OK;
}
else
{
XtraMessageBox.Show("审核失败!" + result, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#endregion
/// <summary>
/// 添加表单到数据库
/// </summary>
/// <param name="ctr"></param>
/// <param name="TableName"></param>
/// <returns></returns>
public bool UpdateForm(int comfirmFlag = 0)
{
//StringBuilder tagFiled = new StringBuilder();
StringBuilder tagValue = new StringBuilder();
StringBuilder tagSql = new StringBuilder();
string guid = Guid.NewGuid().ToString();
string billsql = string.Empty;
string billitemsql = string.Empty;
//单据头修改拼接
billsql = @"UPDATE " + masterTable + " SET {0} WHERE " + column_prefix + "Billdocument_Id='" + billDocumentId + "'";
foreach (DataRow row in dtBillInfoFiled.Rows)
{
string filedName = "txt_" + row["fieldName"].ToString();
Control[] c = pl_right_main.Controls.Find(filedName, true);
if ((c.Length > 0) && (c[0].Enabled))
{
ControlModelTag tagModel = c[0].Tag as ControlModelTag;
if (tagModel.IsEmpt)
{
if (string.IsNullOrEmpty(c[0].Text))
{
MessageBox.Show("请输入" + tagModel.TipMsg, "输入提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return false;
}
}
if (tagModel.fieldTypeId == ControlType.LabDate ||
tagModel.fieldTypeId == ControlType.LabDateTime ||
tagModel.fieldTypeId == ControlType.LabDateTimeShort ||
tagModel.fieldTypeId == ControlType.LabTime ||
tagModel.fieldTypeId == ControlType.LabShortTime)
{
LabelDateEx labledataEx = c[0] as LabelDateEx;
if (string.IsNullOrEmpty(labledataEx.GetDateTimePicker.CustomFormat.Trim()))
{
tagValue.Append(row["fieldName"] + "=NULL,");
}
else
{
tagValue.Append(row["fieldName"] + "='" + labledataEx.GetDateTimePicker.Value.ToString("yyyy-MM-dd HH:mm:ss") + "',");
}
}
else if (tagModel.fieldTypeId == ControlType.LabComboxValue)
{
LabelComboxEx comb = c[0] as LabelComboxEx;
tagValue.Append(row["fieldName"] + "='" + comb.getComboBox.SelectedValue + "',");
}
else if (tagModel.fieldTypeId == ControlType.LabAutoSeacherValue)
{
AutoSearcher autoSearch = c[0] as AutoSearcher;
tagValue.Append(row["fieldName"] + "='" + autoSearch.ReturnValue + "',");
}
else if (tagModel.fieldTypeId == ControlType.LabMultiSelectValue)
{
LabelLookUp lookup = c[0] as LabelLookUp;
tagValue.Append(row["fieldName"] + "='" + lookup.ReturnValue + "',");
}
else
{
tagValue.Append(row["fieldName"] + "='" + c[0].Text + "',");
}
}
}
billsql = string.Format(billsql, tagValue.ToString().Trim(','));
if (tagValue.ToString().Trim() == "")
billsql = "";
//MessageBox.Show(billsql);
//单据头拼接结束
DataTable dtBillItem = gridBillInfo.gridControl.DataSource as DataTable;
DataColumnCollection dccs = dtBillItem.Columns;
foreach (DataRow row in dtBillItem.Rows)
{
if (row.RowState == DataRowState.Deleted)
continue;
billitemsql = @"insert into " + detailTable + "_temp" + "({0})values({1})";
StringBuilder tagFiled2 = new StringBuilder();
StringBuilder tagValue2 = new StringBuilder();
tagFiled2.Append("sysstr,");
tagValue2.Append("'" + guid + "',");
foreach (DataColumn item in dccs)
{
tagFiled2.Append(item.ColumnName + ",");
string v = row[item.ColumnName] + "";
if (!string.IsNullOrEmpty(v))
{
tagValue2.Append("'" + row[item.ColumnName] + "',");
}
else if (v.IndexOf("guid", StringComparison.OrdinalIgnoreCase) != -1)
{
tagValue2.Append("'" + Guid.NewGuid() + "',");
}
else
{
if (item.DataType.ToString().Contains("Decimal")
|| item.DataType.ToString().Contains("Int32")
)
{
tagValue2.Append("0,");
}
else if (item.DataType.ToString().Contains("DateTime"))
{
tagValue2.Append("NULL,");
}
else
{
tagValue2.Append("'',");
}
}
}
billitemsql = string.Format(billitemsql, tagFiled2.ToString().Trim(','), tagValue2.ToString().Trim(','));
tagSql.Append(billitemsql + ";");
}
if (!String.IsNullOrEmpty(tagSql.ToString()))
{
SqlHelper.ExecuteNonQuery(tagSql.ToString());
}
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
pMsg.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
SqlParameter[] param =
{
new SqlParameter("@Sql",SqlDbType.VarChar,5000),
new SqlParameter("@billdocument_id",SqlDbType.VarChar,500),
new SqlParameter("@tmpstr",SqlDbType.VarChar,5000),
new SqlParameter("@Operatorid",SqlDbType.Int),
new SqlParameter("@Fbilltagid",SqlDbType.Int),
new SqlParameter("@operateway",SqlDbType.Int),
pMsg,
new SqlParameter("@auditFlag", SqlDbType.Int),
new SqlParameter("@comfirmFlag", SqlDbType.Int),
returnValue
};
param[0].Value = billsql;
param[1].Value = billDocumentId;
param[2].Value = guid;
param[3].Value = OperatorId;
param[4].Value = 2;// --1新增,2为修改,3为删除
param[5].Value = billSeq;
param[6].Value = "";
param[7].Value = 1;
param[8].Value = comfirmFlag;
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "P_BillSavePr_3", "billSave", param);
string msg = pMsg.Value.ToString();
int rVaule = Convert.ToInt32(returnValue.Value.ToString());
if (rVaule == 1)
{
//XtraMessageBox.Show("操作失败[(" + rVaule + ")" + msg + "]", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return true;
}
if (rVaule != 9)
{
XtraMessageBox.Show("操作失败[(" + rVaule + ")" + msg + "]", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else
{
if (XtraMessageBox.Show(msg, "询问", MessageBoxButtons.YesNo) == DialogResult.Yes)
UpdateForm(1);
else
return false;
}
return true;
}
#region 返回审核
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());
//int a = Convert.ToInt32(string.IsNullOrWhiteSpace(row[column_prefix + "stepCode"].ToString()) ? "0" : row[column_prefix + "stepCode"].ToString());
frmBackSelect frmSel = new frmBackSelect(DLLCoid, Convert.ToInt32(row[column_prefix + "stepCode"].ToString()), billtype, billDocumentId, masterTable, column_prefix);
DialogResult dlg = frmSel.ShowDialog();
if (dlg != DialogResult.OK)
return -9;
AuditAdvice = frmSel.ComfirmMsg;
return frmSel.SelectStepCode;
}
/// <summary>
/// 返回审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnReturn_Click(object sender, EventArgs e)
{
AuditAdvice = txtRemark.Text;
int ret = this.ExecuteBackSelect(dtBillInfoRow);
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,typeName menuname,'2'+CAST(b.id as varchar(10)) id from wms_billflowOper a,p_systembilltype b where a.modid=b.typeCode and keyvalue='{0}' and stepcode='{1}' and a.stepover=0", billDocumentId, 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,20),
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 = billDocumentId;
param[3].Value = OperatorId;
param[4].Value = OperatorName;
param[5].Value = AuditAdvice;
param[6].Value = "R";
param[7].Value = "";
param[8].Value = ret;
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_BillAudit", "bill", param);
string result = msg.Value + "";
if (result == "1")
{
XtraMessageBox.Show("反退成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// 推送消息
//PushHelper.push_bill_oper_message(billDocumentId, stepCode, DLLCoid, beforeusers, beforemenuname, beforeid);
PushHelper push = new PushHelper(billDocumentId, stepCode, DLLCoid, beforeusers, beforemenuname, beforeid);
push.push_bill_oper_message();
this.DialogResult = DialogResult.OK;
}
else
{
XtraMessageBox.Show("反退失败!" + result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
#endregion
private void gridView1_CustomDrawRowIndicator(object sender, RowIndicatorCustomDrawEventArgs e)
{
e.Appearance.TextOptions.HAlignment = HorzAlignment.Center;
if (e.Info.IsRowIndicator)
{
if (e.RowHandle >= 0)
{
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
}
}
private void gridView1_RowStyle(object sender, RowStyleEventArgs e)
{
if (e.RowHandle >= 0)
{
DataRow row = gridView1.GetDataRow(e.RowHandle);
if (row["sh"] + "" == "审")
{
e.Appearance.ForeColor = Color.Blue;
}
}
}
private void btnAtt_Click(object sender, EventArgs e)
{
string[] str = {
FormText,
OperatorId,
OperatorName,
Privilege,
DLLCoid,
billDocumentId,
"1",
DirId,
""
};
IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str);
form.SubForm.ShowDialog();
}
private void btnSave_Click(object sender, EventArgs e)
{
bool updateOk = UpdateForm();
if (updateOk)
{
XtraMessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
XtraMessageBox.Show("保存失败-联系管理员", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
/// <summary>
/// 点击常用工具按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void dpbTools_Click(object sender, EventArgs e)
{
foreach (BarItemLink itemLink in pMenu.ItemLinks)
{
if (itemLink.Item != null)
{
DataRow drItem = itemLink.Item.Tag as DataRow;
var menuCond = drItem["menuCond"] + "";
var menuCaption = itemLink.Caption;
if (!string.IsNullOrEmpty(menuCond))
{
menuCond = PubClass.ReqSqlParam(menuCond, OperatorId, OperatorName);
menuCond = PubClass.ReqSqlWhereEx(pl_right_main, menuCond);
if (dtBillInfoRow != null)
{
menuCond = PubClass.ReqSqlWhereEx(dtBillInfoRow, menuCond);
}
//MessageBox.Show(menuCond);
List<string> listParm = PubClass.GetParamValue(menuCond);
foreach (string s in listParm)
{
string filedName = s.Replace("{", "").Replace("}", "");
menuCond = menuCond.Replace(s, "0");
}
menuCond = PubClass.SqlToCode(menuCond);
try
{
itemLink.Item.Enabled = Convert.ToBoolean(Lskj.Common.Evaluator.Eval(menuCond));
}
catch (Exception)
{
XtraMessageBox.Show(string.Format("{0} 配置条件错误,请检查.", menuCaption));
}
}
}
}
}
#region 拷贝单元格
private void gridBillInfo_KeyDown(object sender, KeyEventArgs e)
{
if (sender != null && e != null)
{
if (e.Control)
{
GridView gridView = sender as GridView;
GridColumn gridColumn = gridView.FocusedColumn;
if (e.KeyCode == Keys.C || e.KeyCode == Keys.V) // 复制
{
object copyData = e.KeyCode == Keys.C
? gridView.GetFocusedRowCellValue(gridView.FocusedColumn)
: Clipboard.GetData(DataFormats.StringFormat);
if (copyData != null && gridView.FocusedColumn.ColumnEdit is RepositoryItemSearchLookUpEdit)
{
RepositoryItemSearchLookUpEdit lookUpEdit = (gridView.FocusedColumn.ColumnEdit as RepositoryItemSearchLookUpEdit);
DataTable dtData = lookUpEdit.DataSource as DataTable;
string valueField = lookUpEdit.ValueMember;
string displayMember = lookUpEdit.DisplayMember;
if (dtData != null && dtData.Rows.Count > 0)
{
if (e.KeyCode == Keys.C)
{
DataRow drData = dtData.Rows.Cast<DataRow>().FirstOrDefault(x => x[valueField].ToString() == copyData.ToString());
if (drData != null)
copyData = drData[displayMember];
Clipboard.SetDataObject(copyData);
e.Handled = true;
}
if (e.KeyCode == Keys.V)
{
DataRow drData = dtData.Rows.Cast<DataRow>().FirstOrDefault(x => x[displayMember].ToString() == copyData.ToString());
if (drData != null)
gridView.SetFocusedRowCellValue(gridView.FocusedColumn, drData[valueField]);
}
}
}
else if (copyData != null)
{
Clipboard.SetDataObject((sender as GridView).GetFocusedRowCellValue((sender as GridView).FocusedColumn));
}
}
}
}
}
#endregion
private void FrmAccraditation_SizeChanged(object sender, EventArgs e)
{
splitContainerControl1.SplitterPosition = splitContainerControl1.Width - 250;
}
}
}