/// <summary> /// 记录到本地 /// </summary> /// <returns></returns> private bool RecordFillInfoToLocal(string palletID, string batchID, string[] batteryIDs, ref string reStr) { // 1、 查询批次信息表(TB_Batch_Index)得到批次编号和批次类型 // 2、 插入托盘信息到托盘信息表(TB_Tray_index)中 // 3、 更新批次信息表(TB_Batch_Index)中托盘数量和电池总数量 // 4、 插入电池信息到电池信息表(TB_After_GradeData) reStr = ""; try { TB_Batch_IndexModel batchModel = gxBatchBll.GetModel(batchID); if (batchModel == null) { reStr = "批次:" + batchID + "不存在"; return(false); } //1 检查托盘信息 if (ocvPalletBll.Exists(palletID)) { reStr = "托盘:" + palletID + "已经存在"; return(false); } //2 坚持查电芯数据是否合格 for (int i = 0; i < batteryIDs.Count() - 1; i++) { int row1 = i / 12 + 1; int col1 = i - (row1 - 1) * 12 + 1; if (string.IsNullOrWhiteSpace(batteryIDs[i])) { continue; } if (batteryIDs[i].Length < 12) //电芯条码升级为13位,,2015-07-23 { reStr = "输入电芯条码错误:第" + (i + 1).ToString() + "个电芯条码不足12位"; return(false); } for (int j = i + 1; j < batteryIDs.Count(); j++) { int row2 = j / 12 + 1; int col2 = j - (row2 - 1) * 12 + 1; if (batteryIDs[i] == batteryIDs[j]) { reStr = "输入电芯条码有重复:第[" + row1.ToString() + "行," + col1.ToString() + "列]和[" + row2.ToString() + "行," + col2.ToString() + "列]电芯条码有重复"; return(false); } } } OCVPalletModel palletModel = new OCVPalletModel(); palletModel.palletID = palletID; palletModel.batchID = batchID; palletModel.loadInTime = System.DateTime.Now; palletModel.processStatus = "A1库老化"; ocvPalletBll.Add(palletModel); for (int i = 0; i < batteryIDs.Count(); i++) { if (string.IsNullOrWhiteSpace(batteryIDs[i]) || batteryIDs[i].Length < 12) //电芯条码升级为13位,modify by zwx,2015-07-23 { continue; } OCVBatteryModel battery = new OCVBatteryModel(); battery.batteryID = batteryIDs[i]; battery.checkResult = "良品"; //初始值假设为合格品 battery.rowIndex = i / 12 + 1; battery.columnIndex = i - (battery.rowIndex - 1) * 12 + 1; battery.hasBattery = true; battery.palletID = palletID; battery.positionCode = (i + 1); ocvBatteryBll.Add(battery); } return(true); } catch (System.Exception ex) { ocvPalletBll.Delete(palletID); MessageBox.Show("录入数据库出现异常,可能有重复的电芯条码,请检查," + ex.Message); return(false); } }
/// <summary> /// 上传电芯数据到客户的数据库系统 /// </summary> /// <param name="palletID"></param> /// <param name="batchID"></param> /// <param name="batteryIDs"></param> /// <param name="reStr"></param> /// <returns></returns> private bool UploadFillInfoToGX(string palletID, string batchID, string[] batteryIDs, bool batchNumEnable, ref string reStr) { // 1、 查询批次信息表(TB_Batch_Index)得到批次编号和批次类型 // 2、 插入托盘信息到托盘信息表(TB_Tray_index)中 // 3、 更新批次信息表(TB_Batch_Index)中托盘数量和电池总数量 // 4、 插入电池信息到电池信息表(TB_After_GradeData) reStr = ""; try { TB_Batch_IndexModel batchModel = gxBatchBll.GetModel(batchID); if (batchModel == null) { reStr = "批次:" + batchID + "不存在"; return(false); } //1 检查托盘信息 if (gxTrayBll.Exists(palletID)) { reStr = "托盘:" + palletID + "已经存在"; return(false); } //2 坚持查电芯数据是否合格 for (int i = 0; i < batteryIDs.Count() - 1; i++) { int row1 = i / 12 + 1; int col1 = i - (row1 - 1) * 12 + 1; if (string.IsNullOrWhiteSpace(batteryIDs[i])) { continue; } if (batteryIDs[i].Length < 12) //modify by zwx,2015-07-23 { reStr = "输入电芯条码错误:第" + (i + 1).ToString() + "个电芯条码不足12位"; return(false); } for (int j = i + 1; j < batteryIDs.Count(); j++) { int row2 = j / 12 + 1; int col2 = j - (row2 - 1) * 12 + 1; if (batteryIDs[i] == batteryIDs[j]) { reStr = "输入电芯条码有重复:第[" + row1.ToString() + "行," + col1.ToString() + "列]和[" + row2.ToString() + "行," + col2.ToString() + "列]电芯条码有重复"; return(false); } } } TB_Tray_indexModel trayModel = new TB_Tray_indexModel(); trayModel.Tf_BatchID = batchID; trayModel.Tf_Batchtype = batchModel.Tf_Batchtype; trayModel.Tf_CellCount = 0; trayModel.Tf_TrayId = palletID; trayModel.tf_CheckInTime = System.DateTime.Now; gxTrayBll.Add(trayModel); //3插入电池信息 int batteryCount = 0; for (int i = 0; i < batteryIDs.Count(); i++) { if (string.IsNullOrWhiteSpace(batteryIDs[i]) || batteryIDs[i].Length < 12) //modify by zwx,2015-07-23 { continue; } //若已存在电芯,更新其绑定的托盘号 List <TB_After_GradeDataModel> batteryList = gxBatteryBll.GetModelList("Tf_CellSn = '" + batteryIDs[i] + "' and Tf_BatchID='" + batchID + "' ");// modify by zwx,2015-12-13 if (batteryList != null && batteryList.Count > 0) { TB_After_GradeDataModel battery = batteryList[0]; if (battery != null) { string oldTrayID = battery.Tf_TrayId; battery.Tf_TrayId = palletID; battery.Tf_BatchID = batchID; battery.Tf_ChannelNo = (i + 1); battery.Tf_Pick = null; battery.Tf_Tag = 0; gxBatteryBll.Update(battery, oldTrayID); batteryCount++; } } else { TB_After_GradeDataModel batteryModel = new TB_After_GradeDataModel(); batteryModel.Tf_BatchID = batchID; batteryModel.Tf_Batchtype = batchModel.Tf_Batchtype; batteryModel.Tf_TrayId = palletID; batteryModel.Tf_ChannelNo = (i + 1); batteryModel.Tf_CellSn = batteryIDs[i]; if (gxBatteryBll.Add(batteryModel)) { batteryCount++; } } } trayModel.Tf_CellCount = batteryCount; if (!gxTrayBll.Update(trayModel)) { reStr = "更新托盘数据表出现错误"; ocvPalletBll.Delete(palletID); string strWhere = "Tf_TrayId='" + palletID + "' and Tf_BatchID='" + batchID + "' "; List <TB_After_GradeDataModel> batteryList = gxBatteryBll.GetModelList(strWhere); foreach (TB_After_GradeDataModel battery in batteryList) { if (battery == null) { continue; } gxBatteryBll.Delete(battery.Tf_BatchID, battery.Tf_TrayId, battery.Tf_CellSn); } gxTrayBll.Delete(palletID); return(false); } //2 更新批次信息 batchModel.Tf_TrayCount++; if (batchNumEnable) { batchModel.Tf_CellCount += trayModel.Tf_CellCount; } gxBatchBll.Update(batchModel); return(true); } catch (System.Exception ex) { string strWhere = "Tf_TrayId='" + palletID + "' and Tf_BatchID='" + batchID + "' "; List <TB_After_GradeDataModel> batteryList = gxBatteryBll.GetModelList(strWhere); foreach (TB_After_GradeDataModel battery in batteryList) { if (battery == null) { continue; } gxBatteryBll.Delete(battery.Tf_BatchID, battery.Tf_TrayId, battery.Tf_CellSn); } gxTrayBll.Delete(palletID); MessageBox.Show("录入数据库出现异常,可能有重复的电芯条码,请检查," + ex.Message); return(false); } }
private void Modify_BatteryInfo() { string batchID = this.comboBoxNewBatch_XG.Text; string batteyID = this.textBoxNewBatteryID_XG.Text; if (string.IsNullOrWhiteSpace(batchID)) { MessageBox.Show("未设定批次"); return; } if (string.IsNullOrWhiteSpace(batteyID)) { MessageBox.Show("电芯条码为空"); return; } TB_Batch_IndexModel batchModel = gxBatchBll.GetModel(batchID); if (batchModel == null) { MessageBox.Show("批次不存在"); return; } if (string.IsNullOrWhiteSpace(this.CurrentBatteryID)) { //新插入 TB_After_GradeDataModel batteryModel = new TB_After_GradeDataModel(); batteryModel.Tf_BatchID = batchID; batteryModel.Tf_Batchtype = batchModel.Tf_Batchtype; batteryModel.Tf_TrayId = this.PalletID; batteryModel.Tf_ChannelNo = this.batteryPos; batteryModel.Tf_CellSn = batteyID; if (!gxBatteryBll.Add(batteryModel)) { MessageBox.Show("提交失败!"); return; } OCVBatteryModel battery = new OCVBatteryModel(); battery.batteryID = batteyID; battery.checkResult = "良品"; //初始值假设为合格品 battery.rowIndex = this.batteryPos / 12 + 1; battery.columnIndex = this.batteryPos - (battery.rowIndex - 1) * 12 + 1; battery.hasBattery = true; battery.palletID = this.PalletID; battery.positionCode = this.batteryPos; if (ocvBatteryBll.Add(battery)) { MessageBox.Show("提交成功!"); } } else { //更新 TB_After_GradeDataModel batteryModel = gxBatteryBll.GetModel(this.CurrentBatchID, PalletID, this.CurrentBatteryID); if (batteryModel == null) { MessageBox.Show("不存在的电芯"); return; } batteryModel.Tf_BatchID = batchID; batteryModel.Tf_CellSn = batteyID; if (gxBatteryBll.Update(batteryModel, PalletID)) { MessageBox.Show("提交成功!"); } else { MessageBox.Show("提交失败!"); } } }