Esempio n. 1
0
        private void GetFillInfo(string palletID)
        {
            string dbSet = this.comboBoxDBset_BL.Text;

            if (string.IsNullOrWhiteSpace(dbSet))
            {
                MessageBox.Show("未设定入库类型");
                return;
            }
            if (dbSet == "初入库")
            {
                OCVPalletModel palletModel = ocvPalletBll.GetModel(palletID);
                if (palletModel == null)
                {
                    MessageBox.Show("提示:本地信息库里未找到该托盘号信息");
                    return;
                }
                this.labelWarn.Text              = "";
                this.comboBoxBatch_BL.Text       = palletModel.batchID;
                this.textBoxCurrentBatch_BL.Text = palletModel.batchID;
                this.dataGridViewBatterys_BL.Rows.Clear();
                for (int i = 0; i < 4; i++)
                {
                    //if (i <3)
                    {
                        this.dataGridViewBatterys_BL.Rows.Add();
                    }
                    this.dataGridViewBatterys_BL.RowCount = this.dataGridViewBatterys_BL.Rows.Count;
                    DataGridViewRow dr = this.dataGridViewBatterys_BL.Rows[i];

                    //DataRow dr = dt.NewRow();
                    for (int j = 0; j < 12; j++)
                    {
                        dr.Cells[j].Value = "";
                    }
                }
                string strWhere = "palletID = '" + palletID + "'";
                // List<TB_After_GradeDataModel> batteryList = gxBatteryBll.GetModelList(strWhere);
                List <OCVBatteryModel> batteryList = ocvBatteryBll.GetModelList(strWhere);

                for (int i = 0; i < batteryList.Count(); i++)
                {
                    //TB_After_GradeDataModel battery = batteryList[i];
                    OCVBatteryModel battery = batteryList[i];
                    if (battery == null)
                    {
                        continue;
                    }
                    int             rowIndex = (int)battery.rowIndex - 1;    // (int)(battery.Tf_ChannelNo - 1) / 12;
                    int             cowIndex = (int)battery.columnIndex - 1; // (int)battery.Tf_ChannelNo - rowIndex * 12 - 1;
                    DataGridViewRow dr       = this.dataGridViewBatterys_BL.Rows[rowIndex];
                    dr.Cells[cowIndex].Value = battery.batteryID;            // battery.Tf_CellSn;
                }
            }
            else if (dbSet == "二次分容入库")
            {
                TB_Tray_indexModel trayModel = gxTrayBll.GetModel(palletID);
                if (trayModel == null)
                {
                    MessageBox.Show("提示:国轩托盘信息库里未找到该托盘号信息");
                    return;
                }
                this.labelWarn.Text              = "";
                this.comboBoxBatch_BL.Text       = trayModel.Tf_BatchID;
                this.textBoxCurrentBatch_BL.Text = trayModel.Tf_BatchID;
                if (this.dataGridViewBatterys_BL.Rows.Count > 0)
                {
                    this.dataGridViewBatterys_BL.Rows.Clear();
                }

                for (int i = 0; i < 4; i++)
                {
                    if (i < 3)
                    {
                        this.dataGridViewBatterys_BL.Rows.Add();
                    }
                    this.dataGridViewBatterys_BL.RowCount = this.dataGridViewBatterys_BL.Rows.Count;
                    DataGridViewRow dr = this.dataGridViewBatterys_BL.Rows[i];

                    //DataRow dr = dt.NewRow();
                    for (int j = 0; j < 12; j++)
                    {
                        dr.Cells[j].Value = "";
                    }
                }

                string strWhere = " Tf_TrayId = '" + palletID + "' and Tf_BatchID='" + trayModel.Tf_BatchID + "' ";
                List <TB_After_GradeDataModel> batteryList = gxBatteryBll.GetModelList(strWhere);
                for (int i = 0; i < batteryList.Count(); i++)
                {
                    TB_After_GradeDataModel battery = batteryList[i];
                    if (battery == null)
                    {
                        continue;
                    }
                    int             rowIndex = (int)(battery.Tf_ChannelNo - 1) / 12;
                    int             cowIndex = (int)battery.Tf_ChannelNo - rowIndex * 12 - 1;
                    DataGridViewRow dr       = this.dataGridViewBatterys_BL.Rows[rowIndex];
                    dr.Cells[cowIndex].Value = battery.Tf_CellSn;
                }
            }
            else
            {
                MessageBox.Show("入库类型设置错误");
                return;
            }


            this.dataGridViewBatterys_BL.BeginEdit(false);
            this.dataGridViewBatterys_BL.CurrentCell = null;
        }
Esempio n. 2
0
        /// <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);
            }
        }
Esempio n. 3
0
        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("提交失败!");
                }
            }
        }