/// <summary> /// 获取未生成交接单的箱主信息和明细信息 /// </summary> /// <returns></returns> public static List <PBBoxInfo> GetUnGenerateBoxListWithDetail() { List <PBBoxInfo> result = null; string sql = @"SELECT * FROM dbo.PBBox WHERE IsGenerate=0 SELECT * FROM dbo.PBBoxDetail WHERE HU IN(SELECT HU FROM dbo.PBBox WHERE IsGenerate = 0)"; DataSet ds = DBHelper.GetDataSet(sql, false); if (ds != null && ds.Tables.Count == 2) { DataTable dtBox = ds.Tables[0]; DataTable dtBoxDetail = ds.Tables[1]; if (dtBox.Rows.Count > 0) { result = new List <PBBoxInfo>(); foreach (DataRow row in dtBox.Rows) { PBBoxInfo item = PBBoxInfo.BuildPBBoxInfo(row); if (dtBoxDetail != null && dtBoxDetail.Rows.Count > 0) { DataRow[] detailRows = dtBoxDetail.Select(string.Format("HU='{0}'", item.HU)); if (detailRows != null && detailRows.Length > 0) { foreach (DataRow detailRow in detailRows) { item.Details.Add(PBBoxDetailInfo.BuildPBBoxDetailInfo(detailRow)); } } } result.Add(item); } } } return(result); }
public static PBBoxInfo GetBoxByHu(string hu) { PBBoxInfo result = new PBBoxInfo(); string sql = string.Format(@"select * from PBBox WHERE HU='{0}' SELECT * FROM PBBoxDetail WHERE HU = '{0}'", hu); DataSet ds = DBHelper.GetDataSet(sql, false); if (ds != null && ds.Tables.Count == 2) { DataTable boxTable = ds.Tables[0]; if (boxTable != null && boxTable.Rows.Count > 0) { result = PBBoxInfo.BuildPBBoxInfo(boxTable.Rows[0]); } else { return(null); } DataTable detailTable = ds.Tables[1]; if (detailTable != null && detailTable.Rows.Count > 0) { foreach (DataRow row in detailTable.Rows) { result.Details.Add(PBBoxDetailInfo.BuildPBBoxDetailInfo(row)); } } } return(result); }
private void button1_Click(object sender, EventArgs e) { List <PBBoxInfo> rowBoxList = new List <PBBoxInfo>(); List <DataGridViewRow> rows = GetCheckedRows(); if (rows != null && rows.Count > 0) { foreach (DataGridViewRow row in rows) { PBBoxInfo box = row.Tag as PBBoxInfo; if (box != null) { if (!rowBoxList.Exists(r => r.HU == box.HU)) { rowBoxList.Add(box); } } } } if (rowBoxList.Count > 0) { if (MetroMessageBox.Show(this, "确认清除列表中箱记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) { if (PackingBoxService.DeleteBoxByHu(rowBoxList.Select(i => i.HU).Distinct().ToList())) { MetroMessageBox.Show(this, "清除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; currentBoxList.RemoveAll(i => rowBoxList.Exists(j => j.HU == i.HU)); updateGrid(); } else { MetroMessageBox.Show(this, "清除失败,可能是网络不稳定,请稍候再试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } //清除提示 //if (boxList != null && boxList.Count > 0) //{ // if (MetroMessageBox.Show(this, "确认清除列表中所有箱记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK) // { // if (PackingBoxService.DeleteBoxByHu(boxList.Select(i => i.HU).Distinct().ToList())) // { // MetroMessageBox.Show(this, "清除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // DialogResult = DialogResult.OK; // Close(); // } // else // { // MetroMessageBox.Show(this, "清除失败,可能是网络不稳定,请稍候再试", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // } // } //} }
private void uploadAgainButton_Click(object sender, EventArgs e) { List <PBBoxInfo> rowBoxList = new List <PBBoxInfo>(); List <DataGridViewRow> rows = GetCheckedRows(); if (rows != null && rows.Count > 0) { foreach (DataGridViewRow row in rows) { PBBoxInfo box = row.Tag as PBBoxInfo; if (box != null) { if (!rowBoxList.Exists(r => r.HU == box.HU)) { rowBoxList.Add(box); } } } } foreach (PBBoxInfo data in rowBoxList) { UploadBoxInfo box = new UploadBoxInfo(); box.EQUIP_HLA = SysConfig.DeviceInfo.EQUIP_HLA; box.LGNUM = SysConfig.LGNUM; box.LOUCENG = SysConfig.DeviceInfo.LOUCENG; box.SUBUSER = SysConfig.CurrentLoginUser.UserId; box.Box = data; SqliteUploadDataInfo ud = new SqliteUploadDataInfo(); ud.Guid = Guid.NewGuid().ToString(); ud.Data = box; ud.IsUpload = 0; ud.CreateTime = DateTime.Now; PackingBoxSqliteService.InsertUploadData(ud); UploadServer.GetInstance().CurrentUploadQueue.Push(ud); } if (rowBoxList.Count > 0) { MetroMessageBox.Show(this, "成功加入上传列表", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Close(); } }
private void Box_OnUploaded(PBBoxInfo Box) { if (currentBoxList == null) { currentBoxList = new List <PBBoxInfo>(); } if (Box.RESULT == "E") { return; } else { currentBoxList.RemoveAll(i => i.HU == Box.HU); currentBoxList.Add(Box); UpdateBtnDocDetailStatus(); UpdateTotalInfo(); } }
/// <summary> /// 获取需要生成交接单的所有箱主信息 /// </summary> /// <returns></returns> public static List <PBBoxInfo> GetNeedGenerateBoxListWithoutDetail() { List <PBBoxInfo> result = null; string sql = @"SELECT * FROM dbo.PBBox WHERE IsGenerate=0"; DataTable dt = DBHelper.GetTable(sql, false); if (dt != null && dt.Rows.Count > 0) { result = new List <PBBoxInfo>(); foreach (DataRow row in dt.Rows) { PBBoxInfo item = PBBoxInfo.BuildPBBoxInfo(row); result.Add(item); } } return(result); }
private void AddBoxDetailGrid(PBBoxInfo box) { if (box == null) { return; } if (box.Details != null && box.Details.Count > 0) { List <string> matnrList = box.Details.Select(i => i.MATNR).Distinct().ToList(); foreach (string item in matnrList) { grid.Rows.Insert(0, box.LH, box.HU, box.Details.Find(i => i.MATNR == item).ZSATNR, box.Details.Find(i => i.MATNR == item).ZCOLSN, box.Details.Find(i => i.MATNR == item).ZSIZTX, box.Details.FindAll(i => i.MATNR == item).Count, box.MSG); if (box.RESULT != "S") { grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed; } grid.Rows[0].Tag = box; } } else { grid.Rows.Insert(0, box.LH, box.HU, "", "", "", 0, box.MSG); if (box.RESULT != "S") { grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed; } grid.Rows[0].Tag = box; } }
public static bool SaveBox(PBBoxInfo box) { //检查是否有已存在的相同的箱码 string ifsql = string.Format(@"SELECT COUNT(1) FROM dbo.PBBox WHERE HU = '{0}' AND RESULT = 'S'", box.HU); if (DBHelper.GetValue(ifsql, false).CastTo <int>(0) > 0) { return(true); } string sql = string.Format(@" delete from PBBox where HU='{0}' delete from PBBoxDetail where HU='{0}'", box.HU); string sql1 = string.Format(@"insert into PBBox(HU,LH,QTY,EQUIP,RESULT,PACKRESULT,PACKMSG,MSG,MX,LIFNR) VALUES('{0}','{1}',{2},'{3}','{4}','{5}','{6}','{7}','{8}','{9}')", box.HU, box.LH, box.QTY, box.EQUIP, box.RESULT, box.PACKRESULT, box.PACKMSG, box.MSG, box.MX, box.LIFNR); string sql2 = ""; if (box.Details != null && box.Details.Count > 0) { sql2 = string.Format(@" insert into PBBoxDetail(EPC,HU,BARCD,MATNR,ZSATNR,ZCOLSN,ZSIZTX,IsAdd) VALUES"); foreach (PBBoxDetailInfo item in box.Details) { string sonsql = string.Format(@"('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7}),", item.EPC, item.HU, item.BARCD, item.MATNR, item.ZSATNR, item.ZCOLSN, item.ZSIZTX, item.IsAdd); sql2 += sonsql; } if (sql2.EndsWith(",")) { sql2 = sql2.Remove(sql2.Length - 1, 1); } } return(DBHelper.ExecuteNonQuery(sql + " " + sql1 + " " + sql2) > 0); }
private void AddBoxDetailGrid(PBBoxInfo box) { if (box == null) { return; } if (box.Details != null && box.Details.Count > 0) { List <string> matnrList = box.Details.Select(i => i.MATNR).Distinct().ToList(); foreach (string item in matnrList) { if (box.PACKRESULT == "E") { grid.Rows.Insert(0, false, box.Timestamps.ToString("yyyy-MM-dd"), box.LH, box.HU, box.PACKRESULT, box.Details.Find(i => i.MATNR == item).ZSATNR, box.Details.Find(i => i.MATNR == item).ZCOLSN, box.Details.Find(i => i.MATNR == item).ZSIZTX, box.PACKMSG); //if (box.PACKRESULT != "S") // grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed; grid.Rows[0].Tag = box; } else { //grid.Rows.Add(box.Timestamps.ToString("yyyy-MM-dd"), // box.LH, box.HU, box.PACKRESULT, // box.Details.Find(i => i.MATNR == item).ZSATNR, // box.Details.Find(i => i.MATNR == item).ZCOLSN, // box.Details.Find(i => i.MATNR == item).ZSIZTX, // box.PACKMSG); //if (box.PACKRESULT != "S") // grid.Rows[grid.Rows.Count-1].DefaultCellStyle.BackColor = Color.OrangeRed; } } } else { if (box.PACKRESULT == "E") { grid.Rows.Insert(0, false, box.Timestamps.ToString("yyyy-MM-dd"), box.LH, box.HU, box.PACKRESULT, "", "", "", box.PACKMSG); //grid.Rows[0].DefaultCellStyle.BackColor = Color.OrangeRed; grid.Rows[0].Tag = box; } else { //grid.Rows.Add(box.Timestamps.ToString("yyyy-MM-dd"), //box.LH, box.HU, box.PACKRESULT, // "", // "", // "", // box.PACKMSG); } } }