protected void ShowMode(PACK_MODE mode) { try { TabPage page = tabWork.TabPages[(int)mode]; page.Select(); m_PackingForm.Parent = page; switch (mode) { case PACK_MODE.Pack: m_PackingForm.Model = m_Pack; break; case PACK_MODE.Carton: m_PackingForm.Model = m_Carton; break; case PACK_MODE.Pallet: m_PackingForm.Model = m_Pallet; break; } m_PackingForm.ShowMode(); page.Controls.Add(m_PackingForm); m_PackingForm.Top = page.ClientRectangle.Top; m_PackingForm.Left = page.ClientRectangle.Left; } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.Message); } }
protected void FillItems(List <CItem> items) { lstItems.Items.Clear(); lstItems.Tag = items; foreach (CItem item in items) { ListViewItem it = lstItems.Items.Add(string.Format("{0}", lstItems.Items.Count + 1)); it.Tag = item; it.SubItems.Add(item.Code); it.SubItems.Add(item.Date.ToString("yyyy-MM-dd HH:mm:ss")); } //设定数量 txtQty.Text = string.Format("{0}", lstItems.Items.Count); if (items.Count > 0) { if (items[0].Name.Equals("pnt_pack")) { txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.PackTrays); m_Mode = PACK_MODE.Pack; } else if (items[0].Name.Equals("pnt_carton")) { txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.CartonPack); m_Mode = PACK_MODE.Carton; } else if (items[0].Name.Equals("pnt_pallet")) { txtTotal.Text = string.Format("{0}", LabelPrintGlobal.g_Config.PalletCarton); m_Mode = PACK_MODE.Pallet; } } }
/// <summary> /// 更新管理表信息 /// </summary> /// <param name="mode">模式:pack, carton, pallet</param> /// <param name="id">箱id</param> /// <param name="user">用户</param> /// <param name="qty">装箱数量</param> /// <param name="action">操作:r=register; c=cancel</param> /// <param name="status">状态:0=BEGIN;1=COMPLETED;2=CANCELED</param> /// <returns></returns> public TPCResult <bool> SetManagerData(PACK_MODE mode, string id, string user, int qty, PACK_ACTION action, PACK_STATUS status) { TPCResult <bool> result = new TPCResult <bool>(); //设定mode string[] MODE_NAME = new string[] { "pack", "carton", "pallet" }; string mode_name = MODE_NAME[(int)mode]; //设定act string[] ACTION_NAME = new string[] { "r", "c" }; string act = ACTION_NAME[(int)action]; string sql = "insert into pnt_mng (pkg_id, pkg_type, act, pkg_date, pkg_qty, pkg_user, pkg_status)" + " values (@id, @type, @act, @date, @qty, @user, @status)"; List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(new DbParameter("@id", DbType.AnsiString, id)); parameters.Add(new DbParameter("@type", DbType.AnsiString, mode_name)); parameters.Add(new DbParameter("@act", DbType.AnsiString, act)); parameters.Add(new DbParameter("@date", DbType.DateTime, DateTime.Now)); parameters.Add(new DbParameter("@qty", DbType.Int32, qty)); parameters.Add(new DbParameter("@status", DbType.Int32, (int)status)); parameters.Add(new DbParameter("@user", DbType.AnsiString, user)); result = Database.Execute(sql, parameters); return(result); }
/// <summary> /// 通过数据库计算lot总数量 /// </summary> /// <param name="mode"></param> /// <param name="code"></param> /// <returns></returns> public TPCResult <int> GetLotTotal(PACK_MODE mode, string code) { TPCResult <int> result = new TPCResult <int>(); string sql = ""; switch (mode) { case PACK_MODE.Pack: sql = "select count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "where pack_id = @code "; break; case PACK_MODE.Carton: sql = "select count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "left join pnt_carton on pnt_pack.pack_id = pnt_carton.pack_id " + "where carton_id = @code "; break; case PACK_MODE.Pallet: sql = "select count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "left join pnt_carton on pnt_pack.pack_id = pnt_carton.pack_id " + "left join pnt_pallet on pnt_carton.carton_id = pnt_pallet.carton_id " + "where pallet_id = @code "; break; } List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(new DbParameter("@code", DbType.AnsiString, code)); TPCResult <DataTable> dt = Database.Query(sql, parameters); if (dt.State == RESULT_STATE.NG) { result.State = RESULT_STATE.NG; result.Message = dt.Message; return(result); } int qty = 0; if (!int.TryParse(dt.Value.Rows[0]["qty"].ToString(), out qty)) { result.State = RESULT_STATE.NG; result.Message = "Get module count failed."; return(result); } result.Value = qty; return(result); }
/// <summary> /// 通过数据库计算module数量 /// </summary> /// <param name="mode"></param> /// <param name="code"></param> /// <returns></returns> public TPCResult <int> GetModuleCount(PACK_MODE mode, string code) { TPCResult <int> result = new TPCResult <int>(); string sql = ""; switch (mode) { case PACK_MODE.Pack: sql = "select count(m.module_id) as qty from t_module m, pnt_pack p" + " where p.tray_id = m.tray_id and p.pack_id = @code " + "and p.status = 1"; break; case PACK_MODE.Carton: sql = "select count(m.module_id) as qty from t_module m, pnt_pack p, pnt_carton c " + "where c.pack_id = p.pack_id and p.tray_id = m.tray_id and c.carton_id = @code " + "and (p.status = 1 and c.status = 1)"; break; case PACK_MODE.Pallet: sql = "select count(m.module_id) as qty from t_module m, pnt_pack p, pnt_carton c, pnt_pallet l " + "where l.carton_id = c.carton_id and c.pack_id = p.pack_id and p.tray_id = m.tray_id and l.pallet_id = @code " + "and (p.status = 1 and c.status = 1 and l.status = 1)"; break; } List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(new DbParameter("@code", DbType.AnsiString, code)); TPCResult <DataTable> dt = Database.Query(sql, parameters); if (dt.State == RESULT_STATE.NG) { result.State = RESULT_STATE.NG; result.Message = dt.Message; return(result); } int qty = 0; if (!int.TryParse(dt.Value.Rows[0]["qty"].ToString(), out qty)) { result.State = RESULT_STATE.NG; result.Message = "Get module count failed."; return(result); } result.Value = qty; return(result); }
/// <summary> /// tab页切换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabWork_SelectedIndexChanged(object sender, EventArgs e) { PACK_MODE mode = (PACK_MODE)tabWork.SelectedIndex; ShowMode(mode); }
/// <summary> /// 构建打印标签参数 /// </summary> /// <param name="data"></param> /// <returns></returns> protected List <string> MakePrintParameters(PACK_MODE mode, PrintLabelData data) { List <string> parameters = new List <string>(); //pegatron P/N 1 parameters.Add(LabelPrintGlobal.g_Config.Pegatoron_PN); //APN 2 parameters.Add(LabelPrintGlobal.g_Config.APN); //REV 3 parameters.Add(LabelPrintGlobal.g_Config.REV); //Config 4 parameters.Add(LabelPrintGlobal.g_Config.Config); //DESC 5 parameters.Add(LabelPrintGlobal.g_Config.DESC); //date 6 parameters.Add(data.DataCode); //L/C 7 parameters.Add(LabelPrintGlobal.g_Config.lc); //Quantity 8 TPCResult <int> qty = Database.GetModuleCount(mode, data.PCode); if (qty.State == RESULT_STATE.NG) { parameters.Add("ERROR QTY"); } else { parameters.Add(qty.Value.ToString()); } //Batch 9 parameters.Add(LabelPrintGlobal.g_Config.batch); //Pack No 10 parameters.Add(data.PCode); //stage 11 parameters.Add(LabelPrintGlobal.g_Config.Stage); //2D barcode 12 string barcode = string.Format("{0},{1},{2},{3},{4},{5},{6}", data.PCode, //pack No LabelPrintGlobal.g_Config.Pegatoron_PN, //PEGA P/N LabelPrintGlobal.g_Config.APN, //APN LabelPrintGlobal.g_Config.batch, //Batch qty.Value.ToString(), //Quantity data.DataCode, //Date LabelPrintGlobal.g_Config.lc); //L/C //Packの場合、特別処理(Erase Pack id at QR code)、2017/11/14(呉) int idx_first = barcode.IndexOf(","); int len_barcode = barcode.Length; switch (mode) { case PACK_MODE.Pack: barcode = barcode.Substring(idx_first + 1, len_barcode - idx_first - 1); break; } parameters.Add(barcode); //修改日期20180518 //13 parameters.Add(LabelPrintGlobal.g_Config.Vendor_PN); //14 parameters.Add(data.Date); //15-46 KeyValuePair <string, string>[] lotCountArray = new KeyValuePair <string, string> [16]; TPCResult <List <KeyValuePair <string, string> > > lotCountList = Database.GetLotCount(mode, data.PCode); int lotSum = 0; if (lotCountList.State == RESULT_STATE.NG) { for (int i = 0; i < 20; i++) { parameters.Add("ERROR"); } } else { Array.Copy(lotCountList.Value.ToArray(), lotCountArray, lotCountList.Value.ToArray().Length); for (int i = 0; i < lotCountArray.Length; i++) { parameters.Add(lotCountArray[i].Key); parameters.Add(lotCountArray[i].Value); lotSum += Convert.ToInt32(lotCountArray[i].Value); } } //other 47, total 48 if (lotSum == 0) { parameters.Add("ERROR"); parameters.Add("ERROR"); } else { TPCResult <int> lotTotal = Database.GetLotTotal(mode, data.PCode); if (lotTotal.State == RESULT_STATE.NG) { parameters.Add("ERROR"); parameters.Add("ERROR"); } else { int other = lotTotal.Value - lotSum; parameters.Add(other.ToString()); parameters.Add(lotTotal.Value.ToString()); } } lotSum = 0; //49 parameters.Add(LabelPrintGlobal.g_Config.Mfr); //end return(parameters); }
/// <summary> /// 通过数据库计算lot数量 修改时间20180518 /// </summary> /// <param name="mode"></param> /// <param name="code"></param> /// <returns></returns> public TPCResult <List <KeyValuePair <string, string> > > GetLotCount(PACK_MODE mode, string code) { TPCResult <List <KeyValuePair <string, string> > > result = new TPCResult <List <KeyValuePair <string, string> > >(); string sql = ""; switch (mode) { case PACK_MODE.Pack: sql = "select lot ,count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "where pack_id = @code group by lot order by qty desc ,lot limit 16"; break; case PACK_MODE.Carton: sql = "select lot ,count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "left join pnt_carton on pnt_pack.pack_id = pnt_carton.pack_id " + "where carton_id = @code group by lot order by qty desc ,lot limit 16"; break; case PACK_MODE.Pallet: sql = "select lot ,count(lot) as qty from t_module left join pnt_pack on t_module.tray_id = pnt_pack.tray_id " + "left join pnt_carton on pnt_pack.pack_id = pnt_carton.pack_id " + "left join pnt_pallet on pnt_carton.carton_id = pnt_pallet.carton_id " + "where pallet_id = @code group by lot order by qty desc ,lot limit 16"; break; } List <DbParameter> parameters = new List <DbParameter>(); parameters.Add(new DbParameter("@code", DbType.AnsiString, code)); TPCResult <DataTable> dt = Database.Query(sql, parameters); if (dt.State == RESULT_STATE.NG) { result.State = RESULT_STATE.NG; result.Message = dt.Message; return(result); } List <KeyValuePair <string, string> > lotCount = new List <KeyValuePair <string, string> >(); for (int i = 0; i < dt.Value.Rows.Count; i++) { int qty = 0; string lotName = ""; string lotNum = ""; lotName = dt.Value.Rows[i]["lot"].ToString(); if (!int.TryParse(dt.Value.Rows[i]["qty"].ToString(), out qty)) { result.State = RESULT_STATE.NG; result.Message = "Get module count failed."; return(result); } else { lotNum = qty.ToString(); KeyValuePair <string, string> lotQty = new KeyValuePair <string, string>(lotName, lotNum); lotCount.Add(lotQty); } } result.Value = lotCount; return(result); }