1933 lines
82 KiB
C#
1933 lines
82 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Lskj.Common;
|
|
using Lskj.MyControl;
|
|
using CommonLib;
|
|
using System.Data.SqlClient;
|
|
using DevExpress.XtraBars;
|
|
using CommonLib.utils;
|
|
using System.IO;
|
|
using DevExpress.XtraEditors;
|
|
using System.Collections;
|
|
using DevExpress.XtraGrid.Views.Grid;
|
|
using DevExpress.XtraGrid;
|
|
|
|
namespace Lskj.PubModuleDetailInfo
|
|
{
|
|
public partial class Panel_Info : UserControl
|
|
{
|
|
public Panel_Info()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
#region 公用属性
|
|
public string DLLCoid;
|
|
public string OperatorId;
|
|
public string OperatorName;
|
|
public string Privilege;
|
|
public string ModuleId;
|
|
public string FormText;
|
|
public string ModuleDllCoid { get; set; }
|
|
public FrmMain parent;
|
|
public string IsView { get; set; }
|
|
public string ObjectId { get; set; }
|
|
public string SpeciesNo { get; set; }
|
|
public string SpeciesName { get; set; }
|
|
public string Ostr1 { get; set; }
|
|
public string dllSql { get; set; }
|
|
public string jsonData { get; set; }
|
|
public string SearchObject;
|
|
public GridControl gc;
|
|
public string MenuSaveStateObj;
|
|
#endregion
|
|
|
|
#region 私有属性
|
|
private string defaultDirId;
|
|
private bool canInit;
|
|
private string column_prefix;
|
|
/// <summary>
|
|
/// 加载表单key
|
|
/// </summary>
|
|
private string Formkey = string.Empty;
|
|
/// <summary>
|
|
/// 查询分类Sql
|
|
/// </summary>
|
|
private string fieldsql = string.Empty;
|
|
/// <summary>
|
|
/// 操作表名
|
|
/// </summary>
|
|
private string TableName = string.Empty;
|
|
/// <summary>
|
|
/// 上传附件目录Id
|
|
/// </summary>
|
|
private int dirid = 0;
|
|
private string bmpSpec = "01";
|
|
/// <summary>
|
|
/// 主键名称
|
|
/// </summary>
|
|
private string FiledNameKey = string.Empty;
|
|
private string FieldNameValue = string.Empty;
|
|
/// <summary>
|
|
/// 操作字段
|
|
/// </summary>
|
|
private DataTable dtFileds;
|
|
private DataTable opFileds;
|
|
private DataRow row_systemDll;
|
|
|
|
/// <summary>
|
|
/// 节点字段
|
|
/// </summary>
|
|
private string speciesField = "SpeciesNo";
|
|
private string speciesKeyField = "SpeciesNo";
|
|
private string speciesNameField = "SpeciesName";
|
|
private MyCreateControl createCtr = new MyCreateControl();
|
|
|
|
private LabelPicFileEx _currentImageEx;
|
|
|
|
private string billPrintSQL;
|
|
private string billPrintSQL1;
|
|
private string billPrintSQL2;
|
|
private string billModuleFile;
|
|
private string billPrintType;
|
|
private string printAddCond;
|
|
private string serverAttachPath;
|
|
private bool CopyAddNew = true;
|
|
private string menuSql;
|
|
private bool SaveComplete = false;
|
|
private bool addVisibleVer = false;
|
|
#endregion
|
|
|
|
public event EventHandler OnAddCallBackEvent;
|
|
public event EventHandler OnUpdateCallBackEvent;
|
|
public event EventHandler OnApplyCallBackEvent;
|
|
public event EventHandler OnCloseCallBackEvent;
|
|
|
|
#region 初始化数据
|
|
/// <summary>
|
|
/// 初始化数据
|
|
/// </summary>
|
|
/// <param name="e"></param>
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
this.canInit = true;
|
|
DLLCoid = !string.IsNullOrEmpty(ModuleDllCoid) ? ModuleDllCoid : DLLCoid;
|
|
|
|
DataTable dtTable = SqlHelper.ExecuteDataTable("select * from P_systemtab");
|
|
if (dtTable != null && dtTable.Rows.Count > 0)
|
|
{
|
|
if (dtTable.Columns.Contains("serverattachpath"))
|
|
serverAttachPath = dtTable.Rows[0]["serverattachpath"] + "";
|
|
}
|
|
|
|
DataTable dtSystemdlltab = SqlHelper.ExecuteDataSet(string.Format("select * from p_systemdlltab where DllCoid='{0}'", DLLCoid)).Tables[0];
|
|
if (dtSystemdlltab.Rows.Count > 0)
|
|
{
|
|
DataRow row = dtSystemdlltab.Rows[0];
|
|
Formkey = row["formKey"] + "";
|
|
billModuleFile = row["printFile"] + "";
|
|
billPrintSQL = row["printSQL"] + "";
|
|
billPrintSQL1 = row["printSQL1"] + "";
|
|
billPrintType = row["printType"] + "";
|
|
this.plTop.Visible = !"lskj.pubadd3.dll".Equals((row["AddDllName"] + "").ToLower());
|
|
bmpSpec = row["bmpSpec"] + "";
|
|
if (billPrintType == "")
|
|
billPrintType = "1";
|
|
billPrintSQL2 = row["printSQL2"] + "";
|
|
menuSql = row["SQL"] + "";
|
|
if (String.IsNullOrEmpty(billModuleFile))
|
|
{
|
|
btnPrint.Visible = false;
|
|
}
|
|
btnPrint.Enabled = !string.IsNullOrEmpty(ObjectId);
|
|
if (dtSystemdlltab.Columns.Contains("addCopyEnabled"))
|
|
{
|
|
CopyAddNew = row["addCopyEnabled"].ToString() == "1";
|
|
}
|
|
btnCopyAdd.Visible = CopyAddNew;
|
|
|
|
defaultDirId = dtSystemdlltab.Rows[0]["dirid"] + "";
|
|
if ((row["dirid"] + "" == "") || (row["dirid"] + "" == "0"))
|
|
btnFile.Visible = false;
|
|
|
|
if (dtSystemdlltab.Columns.Contains("printAddCond"))
|
|
printAddCond = row["printAddCond"] + "";
|
|
|
|
if (dtSystemdlltab.Columns.Contains("SpecVisible"))
|
|
{
|
|
plTop.Visible = dtSystemdlltab.Rows[0]["SpecVisible"] + "" == "1" ? true : false;
|
|
if (!plTop.Visible)
|
|
this.Height = this.Height - plTop.Height;
|
|
}
|
|
|
|
if (dtSystemdlltab.Columns.Contains("addCaption"))
|
|
{
|
|
btnAdd.Text = dtSystemdlltab.Rows[0]["addCaption"] + "" == "" ? "添加保存" : dtSystemdlltab.Rows[0]["addCaption"] + "";
|
|
}
|
|
if (dtSystemdlltab.Columns.Contains("modifyCaption"))
|
|
{
|
|
btnUpdate.Text = dtSystemdlltab.Rows[0]["modifyCaption"] + "" == "" ? "修改保存" : dtSystemdlltab.Rows[0]["modifyCaption"] + "";
|
|
}
|
|
if (dtSystemdlltab.Columns.Contains("applyCaption"))
|
|
{
|
|
btnApply.Text = dtSystemdlltab.Rows[0]["applyCaption"] + "" == "" ? "提交审核" : dtSystemdlltab.Rows[0]["applyCaption"] + "";
|
|
}
|
|
if (dtSystemdlltab.Columns.Contains("saveApplyEnabled"))
|
|
{
|
|
btnApply.Enabled = string.IsNullOrEmpty(dtSystemdlltab.Rows[0]["saveApplyEnabled"] + "") || dtSystemdlltab.Rows[0]["saveApplyEnabled"] + "" == "1";
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(Formkey))
|
|
{
|
|
PubUtil.WriteLog("模块配置不正确", "PubAdd2.dll");
|
|
return;
|
|
}
|
|
|
|
DataTable baseflow = SqlHelper.ExecuteDataSet(string.Format("select 1 from p_systemdlltabflow where typeCode='{0}'", DLLCoid)).Tables[0];
|
|
if ((baseflow != null) && (baseflow.Rows.Count > 0))
|
|
btnApply.Visible = true;
|
|
else
|
|
btnApply.Visible = false;
|
|
|
|
|
|
txt_SpeciesNo.Text = SpeciesNo;
|
|
txt_SpeciesName.Text = SpeciesName;
|
|
|
|
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];
|
|
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)
|
|
plMain.Width = parentWidth;
|
|
this.Width = parentWidth;
|
|
DataRow row_systemwordbook_key = SqlHelper.ExecuteDataSet("select top 1 * from P_systemwordbooktab where tab='" + DLLCoid + "' order by orderid").Tables[0].Rows[0];
|
|
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 (dtTag3 != null && dtTag3.Rows.Count > 0)
|
|
{
|
|
fieldsql = dtTag3.Rows[0]["fieldsql"] + "";
|
|
if (fieldsql.Substring(1, 5).ToLower().IndexOf("with") == -1)
|
|
fieldsql = "select * from (" + fieldsql + ") xx ";
|
|
fieldsql = PubClass.ReqSqlParam(fieldsql, OperatorId, OperatorName);
|
|
speciesField = dtTag3.Rows[0]["fieldname"] + "";
|
|
speciesKeyField = dtTag3.Rows[0]["fieldsqlid"] + "";
|
|
speciesNameField = dtTag3.Rows[0]["fieldsqlname"] + "";
|
|
}
|
|
TableName = row_systemDll["SQLDT1"] + "";
|
|
//取字段前缀
|
|
column_prefix = PubClass.GetColumnPrefix(TableName);
|
|
|
|
opFileds = SqlHelper.ExecuteDataSet(@"select a.*,a.defaultdate as defaultValue from p_systemwordbooktab a
|
|
inner join sys.columns b on lower(a.fieldname)=lower(b.name) and b.object_id=object_id('" + TableName + "')" +
|
|
" where a.tab='" + DLLCoid + "' and isnull(a.addVisible,0)=0").Tables[0];
|
|
|
|
if (row_systemDll["dirid"] + "" != "")
|
|
dirid = Convert.ToInt32(row_systemDll["dirid"]);
|
|
FiledNameKey = row_systemwordbook_key["fieldname"] + "";
|
|
FieldNameValue = row_systemwordbook_key["defaultdate"] + "";
|
|
if (!string.IsNullOrEmpty(jsonData) && String.IsNullOrEmpty(ObjectId))
|
|
{
|
|
DataTable dtData = JsonUtil.JsonToDataTable(jsonData);
|
|
if (dtData != null && dtData.Rows.Count > 0)
|
|
{
|
|
DataRow dr = dtData.Rows[0];
|
|
foreach (DataRow row in dtFileds.Rows)
|
|
{
|
|
String dValue = row["defaultValue"] + "";
|
|
if (!string.IsNullOrEmpty(dValue))
|
|
{
|
|
List<String> list = PubClass.GetParamValue(dValue);
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
if (list[i].Contains("##"))
|
|
{
|
|
string fileName = list[i].Replace("##", "").Replace("{", "").Replace("}", "");
|
|
if (dtData.Columns[fileName] != null)
|
|
{
|
|
dValue = dValue.Replace(list[i], dr[fileName] + "");
|
|
}
|
|
}
|
|
}
|
|
if (list.Count > 0) row["defaultValue"] = dValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SetUpdatePanelData(ObjectId, IsView);
|
|
|
|
|
|
if (String.IsNullOrEmpty(ObjectId))
|
|
{
|
|
DataTable dtTmp = SqlHelper.ExecuteDataSet("select unionFields,unionValue from p_systemwordbooktab where fieldsqlTag=3 and tab='" + DLLCoid + "'").Tables[0];
|
|
if ((dtTmp != null) && (dtTmp.Rows.Count > 0))
|
|
calcSpecUnionFields(dtTmp.Rows[0][0] + "", dtTmp.Rows[0][1] + "");
|
|
}
|
|
|
|
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();
|
|
}
|
|
InitPMenu();
|
|
DataTable dtObjectData = new DataTable();
|
|
if (!String.IsNullOrEmpty(dllSql) && dllSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
dtObjectData = SqlHelper.ExecuteDataSet(dllSql).Tables[0];
|
|
if (dtObjectData != null && dtObjectData.Rows.Count > 0)
|
|
{
|
|
foreach (DataColumn dc in dtObjectData.Columns)
|
|
{
|
|
Control[] ctr = this.Controls.Find("txt_" + dc.ColumnName, true);
|
|
if (ctr != null && ctr.Length > 0)
|
|
{
|
|
createCtr.SetControlText(ctr[0], dtObjectData.Rows[0][dc] + "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SetPictureExEvent();
|
|
// 设置控件值,通过基础档案查询条件
|
|
setControlTextBySearchControl();
|
|
|
|
// 获取附件
|
|
this.btnFile.Text += "(" + GetFileCount() + ")";
|
|
this.canInit = false;
|
|
|
|
if (!plTop.Visible)
|
|
this.Height = this.Height - plTop.Height;
|
|
|
|
DataRow rows = dtFileds.Rows.Cast<DataRow>().FirstOrDefault(x => x["fieldTypeId"] + "" == "98");
|
|
if (rows != null)
|
|
{
|
|
string uniqueField = rows["fieldName"] + "";
|
|
Control[] controls = this.plMain.Controls.Find("txt_" + uniqueField, true);
|
|
if (controls != null && controls.Length > 0)
|
|
{
|
|
LabelTextEx ctr = controls[0] as LabelTextEx;
|
|
tmbox = ctr;
|
|
//ctr.Focus();
|
|
ctr.GetTextBox.KeyDown += new KeyEventHandler(GetTextBox_KeyDown);
|
|
}
|
|
}
|
|
this.SetFirstControlFoucs();
|
|
this.simpleButton1.PerformClick();
|
|
|
|
}
|
|
public void SetUpdatePanelData(string primaryValue, string canUpdate)
|
|
{
|
|
ObjectId = primaryValue;
|
|
btnUpdate.Enabled = btnClear.Enabled = canUpdate == "1";
|
|
btnApply.Enabled = btnCopyAdd.Enabled = btnAdd.Enabled = canUpdate != "1";
|
|
|
|
CreateControlModel ccm = new CreateControlModel(plMain, "", OperatorId, OperatorName, dtFileds);
|
|
|
|
createCtr.ParentCtr = plMain;
|
|
createCtr.LoginId = OperatorId;
|
|
createCtr.LoginName = OperatorName;
|
|
createCtr.Space = txt_SpeciesNo.Text;
|
|
|
|
if (!string.IsNullOrEmpty(primaryValue))
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(PubClass.ReqSqlParam(PubClass.ReplaceWhereCond(row_systemDll["SQL"] + ""), OperatorId, OperatorName) + " and " + FiledNameKey + "='" + primaryValue + "'").Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
if (this.plTop.Visible)
|
|
{
|
|
string sql = fieldsql + " where " + speciesKeyField + "='" + dt.Rows[0][speciesField] + "'";
|
|
DataTable dtSpaceies = SqlHelper.ExecuteDataSet(sql).Tables[0];
|
|
|
|
if (dtSpaceies != null && dtSpaceies.Rows.Count > 0)
|
|
{
|
|
txt_SpeciesName.Text = dtSpaceies.Rows[0][speciesNameField] + "";
|
|
txt_SpeciesNo.Text = dt.Rows[0][speciesField] + "";
|
|
createCtr.Space = txt_SpeciesNo.Text;
|
|
}
|
|
}
|
|
if (canInit)
|
|
{
|
|
createCtr.CreateControlByModel(ccm);
|
|
|
|
}
|
|
//控件设置参数
|
|
MyControlText myctext = new MyControlText();
|
|
txt_OperatorName.Text = dt.Rows[0][column_prefix + "OperatorName"] + "";
|
|
myctext.dr = dt.Rows[0];
|
|
myctext.dt = dtFileds;
|
|
myctext.ctr = this;
|
|
createCtr.SetControlText(myctext);
|
|
|
|
// 设置图片值
|
|
SetPictureExData(dt.Rows[0]);
|
|
}
|
|
btnFile.Enabled = !string.IsNullOrEmpty(defaultDirId) && defaultDirId != "0";
|
|
btnAdd.Enabled = false;
|
|
btnClear.Enabled = true;
|
|
|
|
}
|
|
else
|
|
{
|
|
btnUpdate.Enabled = false;
|
|
btnCopyAdd.Enabled = false;
|
|
btnFile.Enabled = false;
|
|
if (canInit)
|
|
{
|
|
//注册回车事件
|
|
createCtr.CreateControlByModel(ccm);
|
|
|
|
}
|
|
txt_OperatorName.Text = OperatorName;
|
|
}
|
|
}
|
|
|
|
private LabelTextEx tmbox;
|
|
/// <summary>
|
|
/// 扫码回车事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
void GetTextBox_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
btnSave_Click(sender, e);
|
|
//btnClear_Click(sender,e);新增
|
|
//tmbox.Focus();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置控件值,通过基础档案查询条件
|
|
/// </summary>
|
|
private void setControlTextBySearchControl()
|
|
{
|
|
if (!string.IsNullOrEmpty(SearchObject))
|
|
{
|
|
string[] strFiters = SearchObject.Split('|');
|
|
for (int i = 0; i < strFiters.Length; i++)
|
|
{
|
|
string[] control = strFiters[i].Split('=');
|
|
if (control != null && control.Length == 2)
|
|
{
|
|
string fieldName = control[0];
|
|
string fieldValue = control[1];
|
|
|
|
Control[] ctrs = plMain.Controls.Find("txt_" + fieldName, true);
|
|
|
|
if (ctrs != null && ctrs.Length > 0)
|
|
{
|
|
createCtr.SetControlText(ctrs[0], fieldValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 上传图片相关
|
|
public void SetPictureExEvent()
|
|
{
|
|
foreach (Control item in plMain.Controls)
|
|
{
|
|
if (item is LabelPicFileEx)
|
|
{
|
|
LabelPicFileEx ImageEx = item as LabelPicFileEx;
|
|
ImageEx.UploadEvent += new LabelPicFileEx.UploadEventHander(ImageEx_UploadEvent);
|
|
ImageEx.UnionEvent += new LabelPicFileEx.UnionEventHander(ImageEx_UnionEvent);
|
|
ImageEx.DeleteEvent += new LabelPicFileEx.DeleteEventHander(ImageEx_DeleteEvent);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ImageEx_DeleteEvent(object sender)
|
|
{
|
|
try
|
|
{
|
|
// 刷新当前image
|
|
string colName = _currentImageEx != null ? (_currentImageEx.Tag as Lskj.PubUtils.ControlModelTag).fieldName : "";
|
|
if (!string.IsNullOrEmpty(colName))
|
|
{
|
|
string sqlValue = string.Format("update {0} set {1}='' where {2}='{3}'", TableName, colName, FiledNameKey, ObjectId);
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
|
|
_currentImageEx.CurrentImagePath = string.Empty;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show("删除失败" + ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 刷新图片
|
|
/// </summary>
|
|
public void ImageEx_UnionEvent(object sender)
|
|
{
|
|
try
|
|
{
|
|
string isView = (!string.IsNullOrWhiteSpace(ObjectId) && btnUpdate.Enabled) ? "0" : "1";
|
|
string colName = _currentImageEx != null ? (_currentImageEx.Tag as Lskj.PubUtils.ControlModelTag).fieldName : "";
|
|
|
|
string[] str = {
|
|
FormText,
|
|
OperatorId,
|
|
OperatorName,
|
|
Privilege,
|
|
DLLCoid,
|
|
ObjectId,
|
|
isView,
|
|
dirid+"",
|
|
ModuleId,
|
|
"1", // 是否显示关联按钮
|
|
colName // 需要更新的列
|
|
};
|
|
IForm form = PubUtil.LoadDllForm2("Lskj.PhotoView.dll", str);
|
|
form.SubForm.ShowDialog();
|
|
|
|
// 刷新当前image
|
|
DataTable dt = SqlHelper.ExecuteDataSet(PubClass.ReqSqlParam(PubClass.ReplaceWhereCond(row_systemDll["SQL"] + ""), OperatorId, OperatorName) + " and " + FiledNameKey + "='" + ObjectId + "'").Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
SetPictureExData(dt.Rows[0]);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
XtraMessageBox.Show("关联模块打开失败");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 上传图片
|
|
/// </summary>
|
|
public void ImageEx_UploadEvent(object sender)
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(ObjectId))
|
|
{
|
|
XtraMessageBox.Show("请先保存数据.");
|
|
return;
|
|
}
|
|
_currentImageEx = (sender as LabelPicFileEx);
|
|
|
|
// 保存到本地
|
|
string prefix = "001";
|
|
string imagePath = _currentImageEx.SaveImageToLocal(prefix);
|
|
if (!string.IsNullOrEmpty(imagePath))
|
|
{
|
|
string sName = Path.GetFileName(imagePath).Replace(Path.GetExtension(imagePath), "");
|
|
|
|
object obj = SqlHelper.ExecuteScalar(CommandType.Text, "select dirid from P_fm_DirectoryTab where ParentId=" + dirid + " and PID='" + ObjectId + "'");
|
|
int diectoryId = obj == null ? 0 : Convert.ToInt32(obj);
|
|
if (diectoryId == 0)
|
|
{
|
|
string sqls = "insert into P_fm_DirectoryTab (sName,ParentId,creator,SpeciesNo,relationCode,PID) values('" + ObjectId + "'," + dirid + ",1,'0201',0,'" + ObjectId + "');select @@identity";
|
|
diectoryId = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sqls));
|
|
}
|
|
|
|
fmUpdateDownloadType type = (fmUpdateDownloadType)0;
|
|
TParamsData pd = new TParamsData(type, this.Handle);
|
|
pd.setParent(diectoryId);
|
|
pd.setFilePath(imagePath);
|
|
pd.setLocation(200, 200);
|
|
pd.setSize(800, 500);
|
|
pd.SetfileNumber(prefix);
|
|
pd.SetspecieNo(bmpSpec);
|
|
pd.CallUploadUIEx();
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("发现文件未缓存到本地.");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
XtraMessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 设置图片
|
|
/// </summary>
|
|
public void SetPictureExData(DataRow rowData)
|
|
{
|
|
try
|
|
{
|
|
foreach (Control item in plMain.Controls)
|
|
{
|
|
if (item is LabelPicFileEx)
|
|
{
|
|
_currentImageEx = item as LabelPicFileEx;
|
|
Lskj.PubUtils.ControlModelTag modelTab = _currentImageEx.Tag as Lskj.PubUtils.ControlModelTag;
|
|
|
|
string fieldValue = rowData[modelTab.fieldName] + "";
|
|
if (!string.IsNullOrEmpty(fieldValue))
|
|
{
|
|
string bmp_url = Application.StartupPath + "\\tempfiles\\" + rowData[modelTab.fieldName];
|
|
_currentImageEx.CurrentImagePath = bmp_url;
|
|
if (File.Exists(bmp_url))
|
|
{
|
|
// 加载本地缓存数据
|
|
FileStream fs = File.OpenRead(bmp_url);
|
|
_currentImageEx.GetPictureBox.Image = new Bitmap(fs);
|
|
}
|
|
else
|
|
{
|
|
string sqlValue = string.Format("select top 1 dbo.fun_fm_getAbsolutePath(fileId) filePath from P_fm_FileTab where sName like '%{0}%' order by fileId desc", fieldValue);
|
|
DataTable dtFile = SqlHelper.ExecuteDataTable(sqlValue);
|
|
if (dtFile.Rows.Count > 0)
|
|
{
|
|
string download_url = dtFile.Rows[0]["filePath"] + "";
|
|
// 启用下载
|
|
TParamsData pd = new TParamsData(this.Handle);
|
|
pd.CallDownload(serverAttachPath + download_url);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
protected override void DefWndProc(ref Message m)
|
|
{
|
|
try
|
|
{
|
|
switch (m.Msg)
|
|
{
|
|
//上传附件成功消息接收
|
|
case LSCustomWinMsg.BATCH_UPLOAD_COMPLETED:
|
|
{
|
|
if (_currentImageEx != null)
|
|
{
|
|
|
|
Lskj.PubUtils.ControlModelTag modelTab = _currentImageEx.GetPictureBox.Tag as Lskj.PubUtils.ControlModelTag;
|
|
// 上传成功保存图片名称
|
|
string sqlValue = string.Format("update {0} set {1}='{2}' where {3}='{4}'", TableName, modelTab.fieldName, Path.GetFileName(_currentImageEx.CurrentImagePath), FiledNameKey, ObjectId);
|
|
int result = SqlHelper.ExecuteNonQuery(sqlValue);
|
|
}
|
|
break;
|
|
}
|
|
case LSCustomWinMsg.DOWNLOADCOMPLETED:
|
|
if (_currentImageEx != null)
|
|
{
|
|
string bmpUrl = _currentImageEx.CurrentImagePath;
|
|
if (File.Exists(bmpUrl))
|
|
{
|
|
// 加载本地缓存数据
|
|
FileStream fs = File.OpenRead(bmpUrl);
|
|
_currentImageEx.GetPictureBox.Image = new Bitmap(fs);
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
{
|
|
base.DefWndProc(ref m);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
PubUtil.WriteLog(ex.Message);
|
|
XtraMessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 分类关联字段计算
|
|
/// </summary>
|
|
private void calcSpecUnionFields(string unionFields, string unionValue)
|
|
{
|
|
//根据设置关联字段赋值
|
|
if (!string.IsNullOrEmpty(unionFields.Trim()))
|
|
{
|
|
string[] fields = unionFields.Split(',');
|
|
unionValue = unionValue.Replace("{loginid}", OperatorId).Replace("{loginname}", OperatorName);
|
|
List<string> sql_param = PubClass.GetParamValue(unionValue);
|
|
|
|
foreach (string item in sql_param)
|
|
{
|
|
string ctlName = item.Replace("{", "").Replace("}", "");
|
|
Control[] ctl = this.Controls.Find("txt_" + ctlName, true);
|
|
if (ctl != null && ctl.Length > 0)
|
|
{
|
|
string ctValue = PubControl.GetControlText(ctl[0]);
|
|
if (ctValue.Trim() == "")
|
|
ctValue = "0";
|
|
unionValue = unionValue.Replace(item, ctValue);
|
|
}
|
|
}
|
|
try
|
|
{
|
|
foreach (string singleField in fields)
|
|
{
|
|
Control[] ctl = this.Controls.Find("txt_" + singleField, true);
|
|
if (ctl != null && ctl.Length > 0)
|
|
{
|
|
ctl[0].Text = "";
|
|
}
|
|
}
|
|
DataTable dt = SqlHelper.ExecuteDataSet(unionValue).Tables[0];
|
|
if (dt.Rows.Count < 1) return;
|
|
foreach (string singleField in fields)
|
|
{
|
|
Control[] ctl = this.Controls.Find("txt_" + singleField, true);
|
|
if (ctl != null && ctl.Length > 0)
|
|
{
|
|
PubControl.SetControlText(ctl[0], dt.Rows[0][singleField].ToString());
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
|
|
#region 初始常用工具
|
|
/// <summary>
|
|
/// 初始常用工具
|
|
/// </summary>
|
|
public void InitPMenu()
|
|
{
|
|
string sql = "select * from p_systempopupmenu where menuType=1 and tab='" + DLLCoid + "' and visible=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;
|
|
}
|
|
}
|
|
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.ReqSqlWhere(plMain, menuCond);
|
|
try
|
|
{
|
|
itemLink.Item.Enabled = Convert.ToBoolean(Evaluator.Eval(menuCond));
|
|
}
|
|
catch (Exception)
|
|
{
|
|
XtraMessageBox.Show(string.Format("{0} 配置条件错误,请检查.", menuCaption));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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 = 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<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 = 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<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 = plMain.Controls.Find(fName, true);
|
|
if (c.Length > 0)
|
|
{
|
|
p = p.Replace(s, c[0].Text + "");
|
|
}
|
|
}
|
|
}
|
|
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 = 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<string> 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 btnFile_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(ObjectId))
|
|
{
|
|
XtraMessageBox.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 btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
SaveComplete = false;
|
|
try
|
|
{
|
|
MyControlText cct = new MyControlText();
|
|
cct.dt = opFileds;
|
|
cct.TableName = TableName;
|
|
cct.KeyFieldName = FiledNameKey;
|
|
cct.modid = DLLCoid;
|
|
cct.ctr = this;
|
|
cct.IsAdd = true;
|
|
MyCreateControl mm = new MyCreateControl();
|
|
mm.LoginId = OperatorId;
|
|
mm.LoginName = OperatorName;
|
|
mm.ParentCtr = plMain;
|
|
mm.Space = txt_SpeciesNo.Text;
|
|
|
|
if (!string.IsNullOrEmpty(parent.LeftKey) && !string.IsNullOrEmpty(parent.LeftValue))
|
|
mm.SetControlText(mm.GetControl(parent.LeftKey)[0], parent.LeftValue);
|
|
|
|
string msgs = "";
|
|
int result = mm.SaveOrUpdateForm(cct, true, ref msgs);
|
|
if (result > 0)
|
|
{
|
|
SaveBmp(cct);
|
|
SaveComplete = true;
|
|
|
|
if (!string.IsNullOrEmpty(this.MenuSaveStateObj))
|
|
{
|
|
switch (this.MenuSaveStateObj)
|
|
{
|
|
case "1":
|
|
this.btnCopyAdd.PerformClick();
|
|
break;
|
|
case "2":
|
|
if (this.OnCloseCallBackEvent != null) {
|
|
OnCloseCallBackEvent(null, null);
|
|
}
|
|
break;
|
|
case "0":
|
|
this.btnClear.PerformClick();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//XtraMessageBox.Show("添加数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
Control[] c = this.Controls.Find("txt_" + FiledNameKey, true);
|
|
if (c.Length > 0)
|
|
{
|
|
ObjectId = c[0].Text;
|
|
}
|
|
if (string.IsNullOrEmpty(ObjectId))
|
|
{
|
|
ObjectId = result.ToString();
|
|
}
|
|
btnAdd.Enabled = false;
|
|
btnUpdate.Enabled = true;
|
|
btnCopyAdd.Enabled = true;
|
|
btnFile.Enabled = true;
|
|
btnPrint.Enabled = true;
|
|
|
|
SqlHelper.AddLogTab(DLLCoid, FormText + "-->添加", FormText + "[" + ObjectId + "]", FormText, OperatorName);
|
|
|
|
string[] resultMsgs = msgs.ToLower().Split(',');
|
|
|
|
//0=继续新增,1=复制新增,2=关闭
|
|
string status = string.Empty;
|
|
for (int i = 0; i < resultMsgs.Length; i++)
|
|
{
|
|
bool isTip = msgs.Contains("autoprint=1");
|
|
//刷新
|
|
if (resultMsgs[i].Contains("speciesno="))
|
|
{
|
|
string[] specs = resultMsgs[i].Split('=');
|
|
if (specs.Length == 2)
|
|
{
|
|
parent.RefreshLeftTree(specs[1]);
|
|
}
|
|
}
|
|
//打印
|
|
if (resultMsgs[i].Contains("print=1"))
|
|
{
|
|
this.Print(this.billModuleFile, isTip);
|
|
}
|
|
//打印文件
|
|
if (resultMsgs[i].Contains("printfile="))
|
|
{
|
|
string[] files = resultMsgs[i].Split('=');
|
|
if (files.Length == 2 && !string.IsNullOrEmpty(files[1]))
|
|
{
|
|
string[] printFiles = files[1].Split('|');
|
|
for (int n = 0; n < printFiles.Length; n++)
|
|
{
|
|
if (!string.IsNullOrEmpty(printFiles[n]))
|
|
{
|
|
this.Print(printFiles[n], isTip);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//模块
|
|
if (resultMsgs[i].Contains("module="))
|
|
{
|
|
this.ExecRightMenu(resultMsgs[i]);
|
|
}
|
|
|
|
}
|
|
|
|
// 清空数据
|
|
mm.ClearFormEnabledForInfo(cct);
|
|
}
|
|
if (OnAddCallBackEvent != null)
|
|
{
|
|
OnAddCallBackEvent(sender, e);
|
|
}
|
|
this.SetFirstControlFoucs();
|
|
|
|
|
|
}
|
|
catch (DBConcurrencyException dce)
|
|
{
|
|
// 并发异常
|
|
XtraMessageBox.Show("数据已更新,请刷新后重试.");
|
|
return;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
if (ex.Message.IndexOf("ix", StringComparison.OrdinalIgnoreCase) != -1)
|
|
{
|
|
XtraMessageBox.Show("系统检测到录入信息重复,请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show(ex.StackTrace, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void ExecRightMenu(string menuParam)
|
|
{
|
|
GridView gridView = this.gc.MainView as GridView;
|
|
if (string.IsNullOrEmpty(menuParam) || gridView == null) return;
|
|
string maxWindow = "0";
|
|
|
|
//module=11001^lskj.pubadd3.dll^标题^1^参数1^参数2^参数n
|
|
|
|
string[] modules = menuParam.Split('=');
|
|
if(modules.Length != 2){
|
|
MessageBox.Show("配置错误.请检查.");
|
|
return;
|
|
}
|
|
|
|
string valueParam = modules[1];
|
|
string[] defaultParams = valueParam.Split('^');
|
|
if (defaultParams.Length < 4)
|
|
{
|
|
MessageBox.Show("调用模块配置错误.请检查.");
|
|
return;
|
|
}
|
|
string menuCode = defaultParams[0];
|
|
string dllName = defaultParams[1];
|
|
string menuTitle = defaultParams[2];
|
|
string menuSaveState = defaultParams[3];
|
|
int actionType = dllName.Contains(".dll") ? 2: 3;
|
|
|
|
List<string> valueList = new List<string>();
|
|
for (int i = 4; i < 14; i++)
|
|
{
|
|
valueList.Add(defaultParams.Length > i ? defaultParams[i] : "");
|
|
}
|
|
//List<string> valueList = new List<string>();
|
|
//valueList.Add(defaultParams[4]);
|
|
//valueList.Add(defaultParams[5]);
|
|
//valueList.Add(defaultParams[6]);
|
|
//valueList.Add(defaultParams[7]);
|
|
//valueList.Add(defaultParams[8]);
|
|
//valueList.Add(defaultParams[9]);
|
|
//valueList.Add(defaultParams[10]);
|
|
//valueList.Add(defaultParams[11]);
|
|
//valueList.Add(defaultParams[12]);
|
|
//valueList.Add(defaultParams[13]);
|
|
|
|
string DJH = string.Empty;
|
|
dllName = dllName.Replace("{loginid}", ERPInfo.Instance.EmployeeId.ToString());
|
|
dllName = dllName.Replace("{loginname}", ERPInfo.Instance.EmployeeName.ToString());
|
|
//打开dll
|
|
if (actionType == 2)
|
|
{
|
|
#region 打开DLL
|
|
List<string> paremList = new List<string>();
|
|
foreach (string item in valueList)
|
|
{
|
|
string action_type = string.Empty;
|
|
if (item.Length > 0)
|
|
{
|
|
action_type = item.Substring(0, 1);
|
|
}
|
|
// 解析sql
|
|
if (action_type == "@")
|
|
{
|
|
// 右键菜单假如是调用单据,则参数8和参数9为打开单据新增sql语句
|
|
string sql = item.Replace("@", "");
|
|
sql = PubClass.ReqSqlParam(sql, OperatorId, OperatorName);
|
|
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
|
|
paremList.Add(param);
|
|
}
|
|
else if (action_type == "#")
|
|
{
|
|
string sql = item.Replace("#", "");
|
|
paremList.Add(sql);
|
|
}
|
|
else
|
|
{
|
|
paremList.Add(item);
|
|
}
|
|
}
|
|
if (dllName.ToLower() == "iexplore.exe")
|
|
{
|
|
//MessageBox.Show(paremList[0] + Uri.EscapeUriString(paremList[1]));
|
|
string url = paremList[0] + Uri.EscapeUriString(paremList[1]);
|
|
url = url.Replace("#", "%23");
|
|
System.Diagnostics.Process.Start("iexplore.exe", url);
|
|
}
|
|
if (dllName.ToLower() == "lstest.exe")
|
|
{
|
|
// 为了兼容之前版本,参数10配置为调用附件类型,为空则为打开附件,
|
|
// 1.上传附件(参数1分类SpeciesNo,参数2分类SpeciesName,参数3.目录ID),
|
|
// 2.下载附件(参数1附件目录ID,参数2附件ID列表格式:(123,234,124,563,22)为5个附件括号不传递.)
|
|
// 3.删除附件(参数1附件ID列表格式:(123,234,124,563,22)为5个附件括号不传递.)
|
|
|
|
string param1 = paremList[0];
|
|
string param2 = paremList[1];
|
|
string param3 = paremList[2];
|
|
string fileType = paremList[9];
|
|
switch (fileType)
|
|
{
|
|
case "1":
|
|
{
|
|
if (string.IsNullOrEmpty(param1))
|
|
{
|
|
XtraMessageBox.Show("参数1不正确.未传递分类编号");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(param2))
|
|
{
|
|
XtraMessageBox.Show("参数2不正确.未传递分类名称");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(param3))
|
|
{
|
|
XtraMessageBox.Show("参数3不正确.未传递目录ID");
|
|
return;
|
|
}
|
|
fmUpdateDownloadType type = (fmUpdateDownloadType)0;
|
|
TParamsData pd = new TParamsData(type, this.gc.Handle);
|
|
pd.setLocation(100, 100);
|
|
pd.setSize(800, 500);
|
|
pd.setParent(Convert.ToInt32(param3));
|
|
//文件编码
|
|
pd.SetfileNumber("001");
|
|
//类别编码
|
|
pd.SetspecieNo(param2);
|
|
pd.CallUpdateUIEx();
|
|
break;
|
|
}
|
|
case "2":
|
|
{
|
|
if (string.IsNullOrEmpty(param1))
|
|
{
|
|
XtraMessageBox.Show("参数1不正确.未传递目录ID");
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(param2))
|
|
{
|
|
XtraMessageBox.Show("参数2不正确.未传递附件ID");
|
|
return;
|
|
}
|
|
fmUpdateDownloadType type = (fmUpdateDownloadType)2;
|
|
TParamsData pd = new TParamsData(type, this.gc.Handle);
|
|
pd.setLocation(100, 100);
|
|
pd.setSize(800, 500);
|
|
pd.setParent(Convert.ToInt32(param1));
|
|
string[] strFileIds = param2.Split(',');
|
|
foreach (string sId in strFileIds)
|
|
{
|
|
pd.addFileId(int.Parse(sId));
|
|
}
|
|
pd.CallUpdateUI();
|
|
break;
|
|
}
|
|
case "3":
|
|
{
|
|
if (string.IsNullOrEmpty(param1))
|
|
{
|
|
XtraMessageBox.Show("参数1不正确.未传递目录ID");
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(param2))
|
|
{
|
|
XtraMessageBox.Show("参数2不正确.未传递附件ID");
|
|
return;
|
|
}
|
|
DialogResult drt = MessageBox.Show("附件删除后不可恢复,是否真要删除选中的附件?", "询问", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
if (drt != DialogResult.Yes)
|
|
return;
|
|
|
|
string ids = param2.Trim(',');
|
|
fmUpdateDownloadType type = (fmUpdateDownloadType)2;
|
|
TParamsData pd = new TParamsData(type, this.gc.Handle);
|
|
pd.setLocation(100, 100);
|
|
pd.setSize(800, 500);
|
|
pd.setParent(Convert.ToInt32(param1));
|
|
string[] strFileIds = ids.Split(',');
|
|
foreach (string sId in strFileIds)
|
|
{
|
|
//if (this.AttachOperation(3, ERPInfo.Instance.EmployeeId, ERPInfo.Instance.EmployeeName, "", Convert.ToInt32(sId), "", 0))
|
|
//{
|
|
// pd.addFileId(int.Parse(sId));
|
|
//}
|
|
}
|
|
pd.CallDeleteFile();
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
StringBuilder dfile = new StringBuilder();
|
|
StringBuilder rfile = new StringBuilder();
|
|
|
|
int hwnd = 0;
|
|
|
|
dfile.Append(paremList[0] + paremList[1]);
|
|
rfile = PubUtil.DownloadAttach(dfile, hwnd);
|
|
rfile.Clear();
|
|
rfile.Append(Application.StartupPath + @"\tempfiles\" + System.IO.Path.GetFileName(dfile.ToString()));
|
|
if (System.IO.File.Exists(rfile.ToString()))
|
|
{
|
|
System.Diagnostics.Process.Start(rfile.ToString(), "");
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if (dllName == "Lskj.PhotoView.dll")
|
|
{
|
|
string[] str = {
|
|
FormText,
|
|
OperatorId,
|
|
OperatorName,
|
|
"0",
|
|
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
|
|
{
|
|
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],
|
|
menuSaveState
|
|
};
|
|
IForm form = PubUtil.LoadDllForm(dllName, str);
|
|
|
|
form.SubForm.WindowState = maxWindow == "1" ? FormWindowState.Maximized : FormWindowState.Normal;
|
|
form.SubForm.StartPosition = FormStartPosition.CenterParent;
|
|
form.SubForm.ShowDialog();
|
|
}
|
|
#endregion
|
|
}
|
|
else if (actionType == 3)
|
|
{
|
|
List<string> paremList = new List<string>();
|
|
foreach (string item in valueList)
|
|
{
|
|
string action_type = string.Empty;
|
|
if (item.Length > 0)
|
|
{
|
|
action_type = item.Substring(0, 1);
|
|
}
|
|
if (action_type == "@")
|
|
{
|
|
//解析sql
|
|
string sql = item.Replace("@", "");
|
|
string param = SqlHelper.ExecuteScalar(CommandType.Text, sql) + "";
|
|
paremList.Add(param);
|
|
}
|
|
|
|
else if (action_type == "#")
|
|
{
|
|
string sql = item.Replace("#", "");
|
|
paremList.Add(sql);
|
|
}
|
|
else
|
|
{
|
|
string sql = item;
|
|
paremList.Add(sql);
|
|
}
|
|
}
|
|
PubUtil.LoadDelphiDll(dllName, paremList[0], paremList[1], paremList[2], paremList[3], Convert.ToInt32(paremList[4]), paremList[5]);
|
|
}
|
|
|
|
}
|
|
|
|
private void SetFirstControlFoucs()
|
|
{
|
|
try
|
|
{
|
|
// 定位到第一个可编辑的控件
|
|
DataRow row = opFileds.Select("edit=0").OrderBy(x => x["tabOrder"]).FirstOrDefault();
|
|
if (row != null)
|
|
{
|
|
Control[] ctrs = plMain.Controls.Find("txt_" + row["fieldName"], true);
|
|
if (ctrs != null)
|
|
{
|
|
ctrs[0].Focus();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 修改表单
|
|
private void btnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
SaveComplete = false;
|
|
MyControlText cct = new MyControlText();
|
|
cct.dt = opFileds;
|
|
cct.TableName = TableName;
|
|
cct.KeyFieldName = FiledNameKey;
|
|
cct.modid = DLLCoid;
|
|
cct.where = FiledNameKey + "='" + ObjectId + "'";
|
|
cct.ctr = this;
|
|
MyCreateControl mm = new MyCreateControl();
|
|
mm.LoginName = OperatorName;
|
|
mm.LoginId = OperatorId;
|
|
if (this.plTop.Visible)
|
|
{
|
|
mm.Space = txt_SpeciesNo.Text;
|
|
mm.SpeciesField = speciesField;
|
|
}
|
|
string msgs = "";
|
|
int result = mm.SaveOrUpdateForm(cct, false, ref msgs);
|
|
if (result > 0)
|
|
{
|
|
SaveBmp(cct);
|
|
SaveComplete = true;
|
|
if (OnUpdateCallBackEvent != null)
|
|
{
|
|
OnUpdateCallBackEvent(sender, e);
|
|
}
|
|
XtraMessageBox.Show("修改数据成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
if (!string.IsNullOrEmpty(this.MenuSaveStateObj))
|
|
{
|
|
switch (this.MenuSaveStateObj)
|
|
{
|
|
case "1":
|
|
this.btnCopyAdd.PerformClick();
|
|
break;
|
|
case "2":
|
|
if (this.OnCloseCallBackEvent != null)
|
|
{
|
|
OnCloseCallBackEvent(null, null);
|
|
}
|
|
break;
|
|
case "0":
|
|
this.btnClear.PerformClick();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
SqlHelper.AddLogTab(DLLCoid, FormText + "-->修改", FormText + "[" + ObjectId + "]", FormText, OperatorName);
|
|
}
|
|
public void SavePictureImage()
|
|
{
|
|
fmUpdateDownloadType type = (fmUpdateDownloadType)0;
|
|
TParamsData pd = new TParamsData(type, this.Handle);
|
|
pd.CallSmartClient();
|
|
}
|
|
public void SaveBmp(MyControlText cct)
|
|
{
|
|
string keyValue = string.Empty;
|
|
Control[] ctr_key1 = cct.ctr.Controls.Find("txt_" + cct.KeyFieldName, true);
|
|
if ((ctr_key1 != null) && (ctr_key1.Length > 0))
|
|
{
|
|
keyValue = ctr_key1[0].Text;
|
|
}
|
|
|
|
string fieldName = string.Empty;
|
|
foreach (DataRow row in dtFileds.Rows)
|
|
{
|
|
int fieldTypeId = Convert.ToInt32(row["fieldTypeId"]);
|
|
if (fieldTypeId == 99)
|
|
{
|
|
fieldName = row["fieldName"] + "";
|
|
Control[] ctrs = this.Controls.Find("txt_" + fieldName, true);
|
|
if (ctrs.Length > 0)
|
|
{
|
|
LabelPicEx pic = ctrs[0] as LabelPicEx;
|
|
if (pic.GetPictureBox.Image != null)
|
|
{
|
|
SqlHelper.ExecuteSqlInsertImg("update " + TableName + " set " + fieldName + "=@fs where " + FiledNameKey + "='" + keyValue + "'", PubClass.ConvertImage(pic.GetPictureBox.Image));
|
|
}
|
|
else
|
|
{
|
|
SqlHelper.ExecuteNonQuery("update " + TableName + " set " + fieldName + "=null where " + FiledNameKey + "='" + keyValue + "'");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取附件
|
|
/// <summary>
|
|
/// 获取附件
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private int GetFileCount()
|
|
{
|
|
object obj = SqlHelper.ExecuteScalar(CommandType.Text, "select dirid from P_fm_DirectoryTab where ParentId=" + dirid + " and PID='" + ObjectId + "'");
|
|
int DiectoryId = obj == null ? 0 : Convert.ToInt32(obj);
|
|
if (DiectoryId == 0)
|
|
{
|
|
string sqls = "insert into P_fm_DirectoryTab (sName,ParentId,creator,SpeciesNo,relationCode,PID) values('" + ObjectId + "'," + dirid + ",1,'0201',0,'" + ObjectId + "');select @@identity";
|
|
DiectoryId = Convert.ToInt32(SqlHelper.ExecuteScalar(CommandType.Text, sqls));
|
|
}
|
|
|
|
return SqlHelper.ExecuteDataSet("select 1 from P_fm_FileTab where parentId=" + DiectoryId).Tables[0].Rows.Count;
|
|
}
|
|
#endregion
|
|
|
|
#region 清除
|
|
private void btnClear_Click(object sender, EventArgs e)
|
|
{
|
|
MyControlText cct = new MyControlText();
|
|
cct.dt = dtFileds;
|
|
cct.ctr = this;
|
|
MyCreateControl mm = new MyCreateControl();
|
|
mm.Space = txt_SpeciesNo.Text;
|
|
mm.LoginId = OperatorId;
|
|
mm.LoginName = OperatorName;
|
|
mm.ClearFormEnabled(cct);
|
|
|
|
if (!String.IsNullOrEmpty(dllSql) && dllSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(dllSql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataColumn dc in dt.Columns)
|
|
{
|
|
Control[] ctr = plMain.Controls.Find("txt_" + dc.ColumnName, true);
|
|
if (ctr != null && ctr.Length > 0)
|
|
{
|
|
PubControl.SetControlText(ctr[0], dt.Rows[0][dc] + "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!String.IsNullOrEmpty(dllSql) && dllSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
DataTable dt = SqlHelper.ExecuteDataSet(dllSql).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
foreach (DataColumn dc in dt.Columns)
|
|
{
|
|
Control[] ctr = this.Controls.Find("txt_" + dc.ColumnName, true);
|
|
if (ctr != null && ctr.Length > 0)
|
|
{
|
|
PubControl.SetControlText(ctr[0], dt.Rows[0][dc] + "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
btnAdd.Enabled = true;
|
|
btnUpdate.Enabled = false;
|
|
btnCopyAdd.Enabled = false;
|
|
btnFile.Enabled = false;
|
|
tmbox.Focus();
|
|
//设置新增事件
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 打印
|
|
private void btnPrint_Click(object sender, EventArgs e)
|
|
{
|
|
Print(billModuleFile);
|
|
}
|
|
private void Print(string printFile, bool isTip = true)
|
|
{
|
|
string tmpSql = billPrintSQL;
|
|
string tmpSql1 = billPrintSQL1;
|
|
string tmpSql2 = billPrintSQL2;
|
|
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;
|
|
}
|
|
}
|
|
if (isTip)
|
|
{
|
|
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);
|
|
PubUtil.LoadDelphiDll(path, path, printFile, tmpSql, tmpSql1, Convert.ToInt32(billPrintType), tmpSql2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
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);
|
|
PubUtil.LoadDelphiDll(path, path, printFile, tmpSql, tmpSql1, Convert.ToInt32(billPrintType), tmpSql2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
XtraMessageBox.Show("没有找到要打印数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
MyControlText cct = new MyControlText();
|
|
cct.dt = dtFileds;
|
|
cct.ctr = this;
|
|
cct.KeyFieldName = FiledNameKey;
|
|
MyCreateControl mm = new MyCreateControl();
|
|
mm.Space = txt_SpeciesNo.Text;
|
|
mm.LoginId = OperatorId;
|
|
mm.LoginName = OperatorName;
|
|
mm.SetFormCopyAdd(cct);
|
|
|
|
btnCopyAdd.Enabled = false;
|
|
btnUpdate.Enabled = false;
|
|
btnFile.Enabled = false;
|
|
btnPrint.Enabled = false;
|
|
ObjectId = "";
|
|
btnAdd.Enabled = true;
|
|
}
|
|
|
|
public bool BaseApply()
|
|
{
|
|
DialogResult dlg = XtraMessageBox.Show("是否提交审核?", "询问", MessageBoxButtons.YesNo);
|
|
if (dlg != DialogResult.Yes)
|
|
return false;
|
|
try
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.InputOutput;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@typeCode",SqlDbType.VarChar,20),
|
|
new SqlParameter("@billDocumentId",SqlDbType.VarChar,40),
|
|
new SqlParameter("@Operatorid",SqlDbType.Int),
|
|
new SqlParameter("@operatorName",SqlDbType.VarChar,20),
|
|
new SqlParameter("@comfirmType",SqlDbType.Int),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
Control[] keyControl = this.Controls.Find("txt_" + FiledNameKey, true);
|
|
if ((keyControl == null) || (keyControl.Length < 1))
|
|
{
|
|
XtraMessageBox.Show("没有定义关键字段");
|
|
return false;
|
|
}
|
|
|
|
param[0].Value = DLLCoid;
|
|
param[1].Value = keyControl[0].Text;
|
|
param[2].Value = OperatorId;
|
|
param[3].Value = OperatorName;
|
|
param[4].Value = 1;
|
|
param[5].Value = "";
|
|
DataSet ds = SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_baseApply", "baseApply", param);
|
|
string msg = pMsg.Value.ToString();
|
|
int rVaule = Convert.ToInt32(returnValue.Value.ToString());
|
|
if (rVaule == 1)
|
|
{
|
|
|
|
XtraMessageBox.Show("数据提交审核成功");
|
|
|
|
// 推送消息
|
|
PushHelper push = new PushHelper(keyControl[0].Text, "0", DLLCoid, "", "", 0);
|
|
push.push_base_oper_message();
|
|
|
|
if (OnApplyCallBackEvent != null)
|
|
{
|
|
OnApplyCallBackEvent(null, null);
|
|
}
|
|
}
|
|
else if (rVaule == 99)
|
|
{
|
|
////对话框输入
|
|
//ComfirmDialog.ComfirmDialog cfd = new ComfirmDialog.ComfirmDialog(pMsg.Value + "");
|
|
//DialogResult result = cfd.ShowDialog();
|
|
//if (result == DialogResult.Cancel)
|
|
// return false;
|
|
//string hintMsg = cfd.ComfirmMsg;
|
|
|
|
//SqlParameter pMsg1 = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
//pMsg1.Direction = ParameterDirection.InputOutput;
|
|
//SqlParameter returnValue1 = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
//returnValue1.Direction = ParameterDirection.ReturnValue;
|
|
|
|
//SqlParameter[] param1 =
|
|
//{
|
|
// new SqlParameter("@typeCode",SqlDbType.VarChar,20),
|
|
// new SqlParameter("@billDocumentId",SqlDbType.VarChar,40),
|
|
// new SqlParameter("@Operatorid",SqlDbType.Int),
|
|
// new SqlParameter("@operatorName",SqlDbType.VarChar,20),
|
|
// new SqlParameter("@comfirmType",SqlDbType.Int),
|
|
// pMsg1,
|
|
// returnValue1
|
|
//};
|
|
//param1[0].Value = DLLCoid;
|
|
//param1[1].Value = txt_Billdocument_Id.Text;
|
|
//param1[2].Value = OperatorId;
|
|
//param1[3].Value = OperatorName;
|
|
//param1[4].Value = 1;
|
|
//param1[5].Value = hintMsg;
|
|
//SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "p_billApply", "billApply", param1);
|
|
|
|
//rVaule = Convert.ToInt32(returnValue1.Value.ToString());
|
|
//if (rVaule == 1)
|
|
//{
|
|
// XtraMessageBox.Show("单据提交成功");
|
|
// string billitemsql = "Select * from " + masterTable + " where " + column_prefix + "billdocument_id='" + txt_Billdocument_Id.Text + "'";
|
|
// DataTable tb = SqlHelper.ExecuteDataSet(billitemsql).Tables[0];
|
|
// loadBill(tb.Rows[0]);
|
|
// return true;
|
|
//}
|
|
//else
|
|
//{
|
|
// msg = pMsg1.Value + "";
|
|
// XtraMessageBox.Show(typeName + "单据提交失败[(" + rVaule + ")" + msg + "]");
|
|
// return false;
|
|
//}
|
|
|
|
}
|
|
else if (rVaule != 9)
|
|
{
|
|
XtraMessageBox.Show("数据提交审核失败[(" + rVaule + ")" + msg + "]");
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
XtraMessageBox.Show("数据提交审核失败" + e.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private void btnApply_Click(object sender, EventArgs e)
|
|
{
|
|
//bool retValue = true;
|
|
|
|
//if (ObjectId=="")
|
|
//{
|
|
// XtraMessageBox.Show("请先保存数据");
|
|
// return;
|
|
//}
|
|
SaveComplete = false;
|
|
if (btnAdd.Enabled)
|
|
btnAdd.PerformClick();
|
|
else if (btnUpdate.Enabled)
|
|
btnUpdate.PerformClick();
|
|
if (SaveComplete)
|
|
{
|
|
BaseApply();
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 图片上传对象
|
|
/// </summary>
|
|
public class ImageModel
|
|
{
|
|
public LabelPicFileEx ImageEx;
|
|
}
|
|
}
|
|
}
|