/// <summary> /// 增加一条数据 /// </summary> public bool Add(MesDBAccess.Model.ProductOnlineModel model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MesDBAccess.Model.ProductOnlineModel model) { return(dal.Update(model)); }
private void OnFill() { if (this.HkAccess == null) { return; } string palletID = this.textBoxPallet_BL.Text; if (string.IsNullOrWhiteSpace(palletID)) { MessageBox.Show("托盘号不能为空!"); return; } string reStr = ""; if (palletID.Length != 9 || palletID.Substring(0, 2) != "TP") { MessageBox.Show("托盘条码输入错误,检查是否以TP开始,后面7位数字"); return; } List <ProductOnlineModel> productsBinded = productBll.GetProductsInPallet(palletID); if (productsBinded != null && productsBinded.Count > 0) { int askRe = PoupAskmes(string.Format("托盘{0}处于绑定状态,确定重新装载?现有电池-托盘绑定信息将清除", palletID)); if (1 != askRe) { return; } if (!productBll.UnbindPallet(palletID, ref reStr)) { logRecorder.AddDebugLog(this.Text, string.Format("解绑{0}失败,{1}", palletID, reStr)); return; } else { logRecorder.AddDebugLog(this.Text, string.Format("二次装载操作,手动解绑{0}成功", palletID)); } } List <string> batterList = new List <string>(); string[] batteryIDS = new string[36]; int index = 0; for (int i = 0; i < Math.Min(3, this.dataGridViewBatterys_BL.RowCount); i++) { DataGridViewRow rw = this.dataGridViewBatterys_BL.Rows[i]; if (rw == null) { index += 12; continue; } for (int j = 0; j < 12; j++) { if (rw.Cells[j].Value == null) { batteryIDS[index] = string.Empty; } else { batteryIDS[index] = rw.Cells[j].Value.ToString().Trim(new char[] { ' ', '\r', '\n', 't' }).ToUpper(); if (batteryIDS[index].Length > 22 && batteryIDS[index].Length < 35 && batteryIDS[index].Substring(16, 6).ToUpper() == "17K03C") { batteryIDS[index] = batteryIDS[index].Insert(22, "1"); } //由12位条码改为13位,modify by zwx,2015-07-22 //if (batteryIDS[index].Length > 13) //{ // batteryIDS[index] = batteryIDS[index].Substring(0, 13); //} } index++; } } for (int i = 0; i < batteryIDS.Count(); i++) { batterList.Add(batteryIDS[i]); } string sndStr = ""; //本地绑定数据存储 for (int i = 0; i < batterList.Count(); i++) { string batteryID = batterList[i]; if (string.IsNullOrWhiteSpace(batteryID)) { continue; } if (batteryID.Trim().Length < 35) { continue; } batteryID = batteryID.Substring(0, 35); MesDBAccess.Model.ProductOnlineModel productModel = null; if (productBll.Exists(batteryID)) { productModel = productBll.GetModel(batteryID); productModel.productID = batteryID; productModel.palletID = palletID; productModel.modifyTime = System.DateTime.Now; productModel.stepNO = 0; productModel.productCata = "电芯"; productModel.palletBinded = true; productModel.stationID = "3002"; productModel.tag4 = "二次绑定"; productModel.checkResult = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); if (!productBll.Update(productModel)) { continue; } } else { productModel = new MesDBAccess.Model.ProductOnlineModel(); productModel.onlineTime = System.DateTime.Now; productModel.modifyTime = System.DateTime.Now; productModel.productID = batteryID; productModel.palletID = palletID; productModel.stepNO = 0; productModel.productCata = "电芯"; productModel.palletBinded = true; productModel.stationID = "3002"; productModel.tag4 = "二次绑定"; productModel.checkResult = "0"; if (batteryID.Length > 22) { productModel.batchName = batteryID.Substring(16, 6); } int seq = i + 1; productModel.tag1 = seq.ToString(); int rowIndex = i / 12 + 1; productModel.tag2 = rowIndex.ToString(); int colIndex = i - (rowIndex - 1) * 12 + 1; productModel.tag3 = colIndex.ToString(); if (!productBll.Add(productModel)) { continue; } } } //杭可2次装载 if (!HkAccess.BatteryFill(1, palletID, batterList, ref sndStr, ref reStr)) { logRecorder.AddDebugLog(this.Text, string.Format("手动装载失败,{0},返回错误{1},原始发送数据:{2}", palletID, reStr, sndStr)); } else { logRecorder.AddDebugLog(this.Text, string.Format("手动装载成功,{0}", palletID)); AddProduceRecord(palletID, "手动装载"); } }