using System; using System.Collections.Generic; using System.Text; using DBUtility; using System.Data; using Pub_Class; using System.Windows.Forms; using System.Drawing; namespace SCM { public class ClsPub1 { //public static string WEBSURL = "http://124.70.129.242/WEBS-WMS/WebService1.asmx"; //雅琪诺 //public static string WEBSURL = "http://192.168.1.29/WEBS-WMS/WebService1.asmx"; //圣龙 内网 //public static string WEBSURL = "http://122.227.138.236/WEBS-WMS/WebService1.asmx"; //圣龙(不用) //public static string WEBSURL = "http://220.189.218.154:8092/WEBS-WMS/WebService1.asmx"; //四维尔 新中间层 外网 //public static string WEBSURL = "http://192.168.0.178/WEBS-WMS/WebService1.asmx"; //四维尔 新中间层 内网 //public static string WEBSURL = "http://122.227.199.62:5050/LMESWEBS/WebService1.asmx"; //韩电 外网JIT(不用) //public static string WEBSURL = "http://122.227.199.62:5050/WMSWEBS/WebService1.asmx"; //韩电 外网 //public static string WEBSURL = "http://192.168.10.60/WMSWEBS/WebService1.asmx"; //韩电 内网宁波 //public static string WEBSURL = "http://60.190.50.86:5050/WEBS_CE/WebService1.asmx"; //飞龙 //public static string WEBSURL = "http://192.192.192.13/WMSWEBS/WebService1.asmx"; //卓力 //public static string WEBSURL = "http://120.195.29.36:1230/WEBS-WMS/WebService1.asmx"; //江苏龙亨 public static string WEBSURL = "http://60.191.27.141:8090/WEBS-WMS/WebService1.asmx"; //森楷 //public static string WEBSURL = "http://192.168.63.195/WEBS-WMS/WebService1.asmx"; //public static string WEBSURL = "http://192.168.2.18/WEBS-WMS/WebService1.asmx"; //公司台式机 //public static string WEBSURL = "http://192.168.0.107/WEBS-WMS/WebService1.asmx"; //家 //public static string WEBSURL = "http://47.96.97.237/WEBS-WMS/WebService1.asmx"; //公司服务器 public static long HOrgID = 0; public static string HOrgNumber = ""; public static long HPersonL = 2; // 仓库人员为1,车间人员为2 public static long HPersonWHID = 100225; // 车间人员绑定的仓库ID public static string VersionNew = ""; public static string VersionOld = ""; public static SCM.WMSWeb.WebService1 PubWeb = new SCM.WMSWeb.WebService1(); public static string CreateBillCode(string BillCode, ref string sReturn, bool Add) { SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); oWeb.Url = ClsPub1.WEBSURL; Int64 BillCodeMode; string Profix; Int64 Glida; Int32 CodeLen; string sBillNo = ""; char c = Convert.ToChar("0"); string sKjYear = DateTime.Today.Year.ToString(); string sPeriod = DateTime.Today.Month.ToString(); string sDay = DateTime.Today.Day.ToString(); //得到单据号表 信息 //ClsOracleHelper oCn = new ClsOracleHelper(); DataSet Ds = new DataSet(); Ds = oWeb.getDataSetBySQL("Select * from Gy_BillNumber where BillCode='" + BillCode.Trim() + "'", "Gy_BillNumber", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds.Tables[0].Rows.Count != 0) { BillCodeMode = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["BillCodeMode"].ToString()); Profix = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["Profix"].ToString()); Glida = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["Glida"].ToString()); CodeLen = DBUtility.ClsPub.isInt(Ds.Tables[0].Rows[0]["CodeLen"].ToString()); } else { return ""; } // string sStr; switch (BillCodeMode) { case 0: switch (Glida) { case 0: Ds = oWeb.getDataSetBySQL("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "'", "Gy_MaxNum", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds.Tables[0].Rows.Count != 0) { sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length); sBillNo = Profix.Trim() + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim(); } else //插入新记录 { sStr = new string(c, CodeLen - 1); oWeb.getRunProc("insert into Gy_MaxNum(BillCode,NowNumber) values('" + BillCode.Trim() + "',1)", ref DBUtility.ClsPub.sExeReturnInfo); sBillNo = Profix.Trim() + sStr + 1; } if (Add == true) { oWeb.getRunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "'", ref DBUtility.ClsPub.sExeReturnInfo); } return sBillNo; case 1: return sBillNo; case 2: //当前年当前期间 生成单据号 Ds = oWeb.getDataSetBySQL("Select * from Gy_MaxNum where BillCode='" + BillCode.Trim() + "' and KjYear=" + sKjYear + " and Period=" + sPeriod + " and Day=" + sDay, "Gy_MaxNum", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds.Tables[0].Rows.Count != 0) { sStr = new string(c, CodeLen - (Ds.Tables[0].Rows[0]["NowNumBer"].ToString()).Length); sBillNo = Profix.Trim() + sKjYear + DBUtility.ClsPub.isStrNull(("0" + sPeriod)).Substring(DBUtility.ClsPub.isStrNull(("0" + sPeriod)).Length - 2, 2) + DBUtility.ClsPub.isStrNull(("0" + sDay)).Substring(DBUtility.ClsPub.isStrNull(("0" + sDay)).Length - 2, 2) + sStr + Ds.Tables[0].Rows[0]["NowNumBer"].ToString().Trim(); } else //插入新记录 { sStr = new string(c, CodeLen - 1); oWeb.getRunProc("insert into Gy_Maxnum(BillCode,Kjyear,Period,Day,NowNumber) values('" + BillCode.Trim() + "'," + sKjYear + "," + sPeriod + "," + sDay + ",1)", ref DBUtility.ClsPub.sExeReturnInfo); sBillNo = Profix.Trim() + sKjYear + DBUtility.ClsPub.isStrNull(("0" + sPeriod)).Substring(DBUtility.ClsPub.isStrNull(("0" + sPeriod)).Length - 2, 2) + DBUtility.ClsPub.isStrNull(("0" + sDay)).Substring(DBUtility.ClsPub.isStrNull(("0" + sDay)).Length - 2, 2) + sStr + 1; } if (Add == true) { oWeb.getRunProc("update Gy_Maxnum set NowNumBer=NowNumBer+1 where BillCode='" + BillCode.Trim() + "' and KjYear=" + sKjYear + " and Period=" + sPeriod + " and Day=" + sDay, ref DBUtility.ClsPub.sExeReturnInfo); } return sBillNo; default: return sBillNo; } case 1: return sBillNo; default: return sBillNo; } } public static Int64 CreateBillID(string BillCode, ref string sReturn) { SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); oWeb.Url = WEBSURL; string BillType = ""; DataSet Ds; //ClsOracleHelper oCn = new ClsOracleHelper(); Int64 lID; Ds = oWeb.getDataSetBySQL("select * from Gy_BillNumber with (nolock) where BillCode='" + BillCode.Trim() + "'", "Gy_BillNumber", ref DBUtility.ClsPub.sExeReturnInfo); if (Ds.Tables[0].Rows.Count != 0) { lID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["IDNow"].ToString()); BillType = Ds.Tables[0].Rows[0]["BillType"].ToString().Trim(); } else { lID = 0; } //同类型单据 自增1 if (BillType.Trim() != "") { oWeb.getRunProc("update Gy_BillNumber set IDNow=IDNow+1 where BillType='" + BillType.Trim() + "'", ref DBUtility.ClsPub.sExeReturnInfo); } Ds = null; return lID; } // //检验 最新版本 public static bool CheckUpdate() { SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); oWeb.Url = ClsPub1.WEBSURL; DataSet oDs = new DataSet(); //ClsSqlHelperMaster oCn = new ClsSqlHelperMaster(); string LastNumber1 = ""; string LastNumber2 = ""; string BbNumber = ""; string sTableName = ""; //得到更新表 sTableName = ClsIni.ReadIni("UpDateCounts", "sTableName", Pub_Class.ClsPub.AppPath + @"\" + "UpDatePrj.ini"); if (sTableName == "没有找到!" || sTableName == "") { sTableName = "HX_UPdateForWInce"; } //得到最新版本 try { oDs = oWeb.getDataSetBySQL("select top 1 * from master.." + sTableName + " order by FItemID", sTableName, ref DBUtility.ClsPub.sExeReturnInfo); if (oDs == null || oDs.Tables[0].Rows.Count == 0) { return false; } else { LastNumber1 = oDs.Tables[0].Rows[0]["FNumber"].ToString().Trim(); VersionNew = LastNumber1; } //得到本地版本 LastNumber2 = ClsIni.ReadIni("UpDateCounts", "LastUpdateID", Pub_Class.ClsPub.AppPath + @"\" + "UpDatePrj.ini"); VersionOld = LastNumber2; if (LastNumber2 == "没有找到!") { return false; } if (LastNumber2.Trim().ToUpper() == LastNumber1.Trim().ToUpper()) { return false; } return true; } catch (Exception e) { throw (e); } } // // 读取列宽datagridview public static void GetGridView(DataGridView oGrd, string KeyItem, string AppPath) { int Cols; char c = Convert.ToChar(","); string sStr = ClsIni.ReadIni("GridSave", KeyItem, AppPath + @"\" + "grdWidth.wyini"); if (sStr != "没有找到!") { string[] ColWidth = sStr.Split(c); if (oGrd.ColumnCount > ColWidth.Length) { Cols = ColWidth.Length; } else { Cols = oGrd.ColumnCount; } for (int i = 0; i < Cols; i++) { if (DBUtility.ClsPub.isInt(ColWidth[i]) > 500) { oGrd.Columns[i].Width = DBUtility.ClsPub.isInt(ColWidth[i]); } else { oGrd.Columns[i].Width = DBUtility.ClsPub.isInt(ColWidth[i]); } } } } // 读取隐藏列datagridview 并设置 对齐方式 /// /// 读取隐藏列datagridview 并设置 对齐方式 /// /// /// /// public static void HideGridView(DataGridView oGrd, string KeyItem, string AppPath) { int Cols; char c = Convert.ToChar(","); char s = Convert.ToChar("|"); string sStr = Fun_GetGridStrByModName(KeyItem); if (sStr != "没有找到!") { string[] Col = sStr.Split(c); for (int i = 0; i < Col.Length; i++) { if (i >= oGrd.ColumnCount) { break; } string[] sCol = Col[i].Split(s); if (sCol.Length > 1) { if (DBUtility.ClsPub.isStrNull(sCol[1]) == "1") { oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].Visible = false; //隐藏列 } else { oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].Visible = true; //隐藏列 } //h开头的隐藏 if (oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].HeaderText != "") { if (oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].HeaderText.Substring(0, 1).ToLower() == "h") { oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].Visible = false; } } else { oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].Visible = false; } } // //if (sCol.Length > 2) //{ // if (DBUtility.ClsPub.isStrNull(sCol[2]) == "L") // { // oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; // // } // else if (DBUtility.ClsPub.isStrNull(sCol[2]) == "R") // { // oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; // // } // else if (DBUtility.ClsPub.isStrNull(sCol[2]) == "M") // { // oGrd.Columns[DBUtility.ClsPub.isInt(sCol[0])].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; // // } // else // { // //; // } //} } } } //根据模块名 返回 网格 信息 public static string Fun_GetGridStrByModName(string KeyItem) { try { SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); oWeb.Url = WEBSURL; //ClsOracleHelper oCn = new ClsOracleHelper(); DataSet ds; ds = oWeb.getDataSetBySQL("select top 1 HGridString from Xt_grdAlignment where HUserName='" + DBUtility.ClsPub.CurUserName + "' and HModName='" + KeyItem + "'", "Xt_grdAlignment", ref DBUtility.ClsPub.sExeReturnInfo); if (ds == null || ds.Tables[0].Rows.Count == 0) { //oCn.CnDispose(); //oCn = null; return "没有找到!"; } else { //oCn.CnDispose(); //oCn = null; return DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HGridString"]); } } catch (Exception e) { //oCn.CnDispose(); //oCn = null; return "没有找到!"; } } //初始化网格 public static void initGridFst(DataGridView grdMain, string Name) { grdMain.RowTemplate.Height = 18; //行高设置 grdMain.RowTemplate.MinimumHeight = 18; //最小行高 grdMain.ColumnHeadersHeight = 40; //标题行高 grdMain.RowHeadersVisible = false; //固定列是否显示 grdMain.ColumnHeadersVisible = true; //固定行是否显示 grdMain.RowCount = 1; //总行数 for (int i = 0; i < grdMain.ColumnCount; i++) { grdMain.Columns[i].Width = 100; //设置 列宽 grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable; //列 排序模式 } // grdMain.RowsDefaultCellStyle.SelectionForeColor = Color.Black; //行选中字体颜色 //grdMain.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; //内容布局(居中,靠右) grdMain.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;//标题行布局(居中,靠右 grdMain.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True;//标题行自动换行 grdMain.SelectionMode = DataGridViewSelectionMode.CellSelect; //选行模式 grdMain.ReadOnly = false; //是否只读 grdMain.EditMode = DataGridViewEditMode.EditOnEnter; //编辑模式 grdMain.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //标题行高 调整模式 grdMain.EnableHeadersVisualStyles = false; //标题 显示样式 grdMain.AllowUserToAddRows = false; //是否允许自增--否 grdMain.AllowUserToDeleteRows = false; //是否允许删除--否 grdMain.AllowUserToResizeColumns = true; //允许调整列宽--是 grdMain.AllowUserToResizeRows = false; //允许调整行高--否 grdMain.AllowUserToOrderColumns = false; //是否允许拖拽列 grdMain.BackgroundColor = Color.White; //网格背景色 grdMain.GridColor = Color.LightGray; //网格线颜色 grdMain.DefaultCellStyle.SelectionBackColor = Color.AntiqueWhite; //选中时背景颜色 grdMain.ShowCellToolTips = false; //鼠标停留 显示提示 grdMain.ColumnHeadersDefaultCellStyle.BackColor = Color.LightSteelBlue; //标题列 背景色 ClsPub1.GetGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//设置列宽 ClsPub1.HideGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//设置列宽 grdMain.RowCount = 20; //总行数(更改行数时,会触发 编辑前事件) } //初始化网格2 public static void initGridLast(string sAllowCol, string sTotalCol, ClsGridViewSum oSumGrid) { string[] sA; string[] sT; sA = sAllowCol.Split(Convert.ToChar(",")); sT = sTotalCol.Split(Convert.ToChar(",")); // oSumGrid.BuildAllowEditCols(sA); oSumGrid.BuildTotalCols(sT); oSumGrid.SetGridsum(); oSumGrid.SetGridMain(); } public static void initGridList(DataGridView grdMain, string Name) { grdMain.RowTemplate.Height = 18; grdMain.RowTemplate.MinimumHeight = 18; grdMain.ColumnHeadersHeight = 40; grdMain.RowHeadersVisible = false; grdMain.ColumnHeadersVisible = true; //grdMain.RowCount = 1; //格式化 //表格设置 grdMain.RowsDefaultCellStyle.SelectionForeColor = Color.White; grdMain.RowsDefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdMain.DefaultCellStyle.SelectionBackColor = Color.DarkCyan; grdMain.DefaultCellStyle.SelectionForeColor = Color.White; //grdMain.RowsDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;//网格内容 对齐方式 grdMain.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //标题列 内容对齐方式 grdMain.SelectionMode = DataGridViewSelectionMode.FullRowSelect; grdMain.ReadOnly = true; grdMain.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing; //允许用户调整列宽 grdMain.EnableHeadersVisualStyles = false; //网格标题 样式 grdMain.AllowUserToAddRows = false; //是否允许自增--否 grdMain.AllowUserToDeleteRows = false; //是否允许删除--否 grdMain.AllowUserToResizeColumns = true; //允许调整列宽--是 grdMain.AllowUserToResizeRows = false; //允许调整行高--否 grdMain.AllowUserToOrderColumns = true; //允许 拖拽列 grdMain.BackgroundColor = Color.White; //网格背景色 grdMain.GridColor = Color.Gainsboro; //网格线颜色 grdMain.ShowCellToolTips = true; grdMain.CellBorderStyle = DataGridViewCellBorderStyle.SingleVertical; //网格线样式:只有竖线 grdMain.ColumnHeadersDefaultCellStyle.BackColor = Color.LightGray; //标题列 背景色 grdMain.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableWithoutHeaderText; //剪贴板模式: //grdMain.ColumnHeadersBorderStyle = DataGridViewHeaderBorderStyle.None; // ClsPub1.GetGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//设置列宽 } //显示列表 /// /// 设置列宽,隐藏列(h开头、用户设置),冻结列,对齐方式 /// /// /// /// /// public static void DisplayGrid(DataGridView grdMain, string Name, string s, int FrCol) { //加载列宽,隐藏列(H开头) for (int i = 0; i < grdMain.ColumnCount; i++) { grdMain.Columns[i].Width = 100;//默认列宽 if (s == "否") { grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;//是否允许 排序列 } else { grdMain.Columns[i].SortMode = DataGridViewColumnSortMode.Automatic; } if (grdMain.Columns[i].HeaderText.Substring(0, 1).ToLower() == "h")//隐藏H开头的列 { grdMain.Columns[i].Visible = false; } else { grdMain.Columns[i].Visible = true; } } for (int i = 0; i < grdMain.ColumnCount; i++)//设置冻结列 { grdMain.Columns[i].Frozen = false; } if (FrCol < grdMain.ColumnCount) { grdMain.Columns[FrCol].Frozen = true;//设置冻结列 } //设置字体大小 及标题行高,内容行高 // ClsPub1.GetGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//设置列宽 ClsPub1.HideGridView(grdMain, Name, DBUtility.ClsPub.AppPath);//读取隐藏列datagridview 并设置 对齐方式 } //得到服务器日期 public static string GetServerDate(Int64 iType) { SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1(); oWeb.Url = WEBSURL; //ClsSqlHelper oCn = new ClsSqlHelper(); DataSet Ds = new DataSet(); try { Ds = oWeb.getDataSetBySQL("Select GetDate() as CurDate", "xt_xtgnb", ref DBUtility.ClsPub.sExeReturnInfo); //Ds = oCn.RunProcReturn("Select GetDate() as CurDate", "xt_xtgnb"); switch (iType) { case 0: return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd"); case 1: return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("HH:mm:ss"); case -1: return Convert.ToDateTime(Ds.Tables[0].Rows[0]["CurDate"]).ToString("yyyy-MM-dd HH:mm:ss"); default: return "1900-01-01"; } } catch (Exception e) { return "1900-01-01"; } } } }