private void FrmReportErrorOfLineByHours_Load(object sender, EventArgs e)
 {
     try
     {
         errors.AddRange(BLLError.GetAll());
         lines.AddRange(BLLLine.GetLines(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList()));
         if (lines != null && lines.Count > 0)
         {
             GetDataForCbbHours();
             if (times != null && times.Count > 0)
             {
                 cbbHours.DataSource    = times;
                 cbbHours.DisplayMember = "Name";
                 GetDataChart();
             }
         }
         else
         {
             MessageBox.Show("Lỗi: Không có thông tin Chuyền", "Thông Báo Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message, "Thông Báo Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void LoadError()
        {
            cbError.DataSource = null;
            var err = BLLError.GetAll();

            cbError.DataSource    = err;
            cbError.DisplayMember = "Name";
            cbError.ValueMember   = "Id";
        }
Example #3
0
 private void LoadDataForGridError()
 {
     try
     {
         gridError.DataSource = BLLError.GetAll();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #4
0
 private void FormSanLuongLoiChuyen_Load(object sender, EventArgs e)
 {
     try
     {
         listError = BLLError.GetAll();//errorDAO.GetListError();
         BuildGridView();
         LoadData();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }
 private void FrmReportCountErrorHours_Load(object sender, EventArgs e)
 {
     try
     {
         listError = BLLError.GetAll(); // errorDAO.GetListError();
         GetDataForCbbLine();
         GetDataChart();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }
Example #6
0
 public bool AddNangSuatCumLoiOfChuyen(int sttChuyenSanPham, int maChuyen)
 {
     try
     {
         bool   result      = false;
         string dateNow     = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;
         var    listCluster = clusterDAO.GetCumOfChuyen(maChuyen);
         if (listCluster != null && listCluster.Count > 0)
         {
             List <string> listQuery = new List <string>();
             foreach (var cluster in listCluster)
             {
                 var listError = BLLError.GetAll(); // errorDAO.GetListError();
                 if (listError != null && listError.Count > 0)
                 {
                     foreach (var error in listError)
                     {
                         string    strSQLCheckExist = "Select Id From NangSuat_CumLoi Where STTChuyenSanPham=" + sttChuyenSanPham + " and IsDeleted=0 and CumId=" + cluster.Id + " and Ngay ='" + dateNow + "' and ErrorId=" + error.Id;
                         DataTable dtCheckExist     = dbclass.TruyVan_TraVe_DataTable(strSQLCheckExist);
                         if (dtCheckExist == null || (dtCheckExist != null && dtCheckExist.Rows.Count == 0))
                         {
                             listQuery.Add("Insert Into NangSuat_CumLoi(Ngay, STTChuyenSanPham, CumId, ErrorId) Values('" + dateNow + "'," + sttChuyenSanPham + ", " + cluster.Id + ", " + error.Id + ")");
                         }
                     }
                 }
             }
             if (listQuery.Count > 0)
             {
                 int rs = dbclass.ExecuteSqlTransaction(listQuery);
                 if (rs > 0)
                 {
                     result = true;
                 }
             }
             else
             {
                 result = true;
             }
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void FrmCauHinhDocSo_Load(object sender, EventArgs e)
 {
     try
     {
         LoadDataToGridView();
         //LoadCbbSoundInt();
         EnableControlSend(true, false, false, false, false);
         ClearInput();
         EnableInputMSend(false);
         var listError = BLLError.GetAll(); // errorDAO.GetListError();
         cbbError1.DataSource    = listError;
         cbbError1.DisplayMember = "Name";
         cbbError2.DataSource    = listError;
         cbbError2.DisplayMember = "Name";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Lỗi: " + ex.Message);
     }
 }
Example #8
0
        /// <summary>
        /// khoi tao lai thong tin keypad cho chuyen
        /// </summary>
        /// <param name="lineId"></param>
        /// <param name="IsResetAllToZero">= true neu reset tat ca ve 0 else neu lay thong tin nang suat hien tai</param>
        /// <param name="frmMainNew"></param>
        /// <returns></returns>
        public static bool ResetKeypad_Moi(int lineId, bool IsResetAllToZero, FrmMainNew frmMainNew)
        {
            try
            {
                var    listMapIdSanPhamNgay = new List <PMS.Data.MapIdSanPhamNgay>();
                string ngay = DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year;

                var    listStrProductConfig = new List <string>();
                var    errors        = BLLError.GetAll();
                string strListChuyen = lineId + ",";
                var    assigns       = BLLProductivity.GetProductivitiesInDay(ngay, lineId);
                if (assigns != null && assigns.Count > 0)
                {
                    var listStrSend        = new List <string>();
                    var listStrSetSanLuong = new List <string>();
                    var sanluongs          = new List <string>();
                    var sttCSP             = new List <int>();
                    int stt = 0;
                    foreach (var item in assigns)
                    {
                        var mapIdSanPhamNgay = new PMS.Data.MapIdSanPhamNgay();
                        mapIdSanPhamNgay.MaChuyen         = item.LineId;
                        mapIdSanPhamNgay.STTChuyenSanPham = item.STTCHuyen_SanPham;
                        mapIdSanPhamNgay.MaSanPham        = item.productId;
                        stt += 1;
                        mapIdSanPhamNgay.STT  = stt;
                        mapIdSanPhamNgay.Ngay = ngay;
                        listMapIdSanPhamNgay.Add(mapIdSanPhamNgay);
                        string strSend    = mapIdSanPhamNgay.STT.ToString() + ",";
                        string tenSanPham = item.ProductName;
                        if (!string.IsNullOrEmpty(tenSanPham))
                        {
                            if (tenSanPham.Length > 10)
                            {
                                strSend += tenSanPham.Substring(0, 10);
                            }
                            else
                            {
                                strSend += tenSanPham;
                            }
                        }
                        listStrSend.Add(strSend);
                        listStrSetSanLuong.Add(mapIdSanPhamNgay.STT.ToString());
                        sttCSP.Add(item.STTCHuyen_SanPham);
                    }

                    //
                    var keypads = BLLKeyPad.GetKeyPadInfoByLineId(lineId);
                    if (keypads != null && keypads.Count > 0)
                    {
                        if (listStrSend.Count > 0 || listStrSetSanLuong.Count > 0)
                        {
                            foreach (var kp_Obj in keypads)
                            {
                                if (kp_Obj.UseTypeId == (int)eUseKeyPadType.OneKeyPadOneObject)
                                {
                                    frmMainNew.listDataSendKeyPad.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ClearData + ",,");
                                    Thread.Sleep(500);
                                    foreach (var strSend in listStrSend)
                                    {
                                        listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ProductConfig + "," + strSend);
                                    }
                                    if (IsResetAllToZero) // reset keypad + reset so lieu ve 0
                                    {
                                        #region
                                        foreach (var strSend in listStrSetSanLuong)
                                        {
                                            // listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + strSend + ",0,1,");
                                            if (errors != null && errors.Count > 0)
                                            {
                                                foreach (var error in errors)
                                                {
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductError + "," + strSend + ",0," + error.Code);
                                                }
                                            }

                                            switch (kp_Obj.TypeOfKeypad)
                                            {
                                            case (int)eTypeOfKeypad.All:
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + strSend + ",0," + (int)eProductOutputType.KCS);
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + strSend + ",0," + (int)eProductOutputType.TC);
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + strSend + ",0,,");
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + strSend + ",0,1,");
                                                break;

                                            case (int)eTypeOfKeypad.KCS:
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + strSend + ",0," + (int)eProductOutputType.KCS);
                                                break;

                                            case (int)eTypeOfKeypad.TC:
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + strSend + ",0," + (int)eProductOutputType.TC);
                                                break;

                                            case (int)eTypeOfKeypad.BTP:
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + strSend + ",0,,");
                                                listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + strSend + ",0,1,");
                                                break;
                                            }
                                        }
                                        #endregion
                                    }
                                    else   // chi reset keypad van giu so lieu cũ
                                    {
                                        for (int i = 0; i < listStrSetSanLuong.Count; i++)
                                        {
                                            var nxInDay = BLLProductivity.GetProductivitiesInDay(DateTime.Now, sttCSP[i]);
                                            if (nxInDay != null)
                                            {
                                                var tdns = BLLDayInfo.GetByCommoId(sttCSP[i], nxInDay.productId, frmMainNew.todayStr).Where(x => x.EquipmentId == kp_Obj.EquipmentId).ToList();
                                                var btps = BLLDayInfo.GetBTPNgay(sttCSP[i], frmMainNew.todayStr).Where(x => x.EquipmentId == kp_Obj.EquipmentId).ToList();

                                                var quantities = 0;

                                                if (errors != null && errors.Count > 0)
                                                {
                                                    foreach (var error in errors)
                                                    {
                                                        quantities  = tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorIncrease && c.ErrorId.HasValue && c.ErrorId.Value == error.Id).Sum(c => c.ThanhPham);
                                                        quantities -= tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorReduce && c.ErrorId.HasValue && c.ErrorId.Value == error.Id).Sum(c => c.ThanhPham);
                                                        listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductError + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + "," + error.Code);
                                                    }
                                                }

                                                switch (kp_Obj.TypeOfKeypad)
                                                {
                                                case (int)eTypeOfKeypad.All:
                                                    quantities  = tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    quantities -= tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.KCS);

                                                    quantities  = tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    quantities -= tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.TC);

                                                    quantities  = btps.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                                    quantities -= btps.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + ",,");
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + listStrSetSanLuong[i] + "," + 0 + ",1");
                                                    break;

                                                case (int)eTypeOfKeypad.KCS:
                                                    quantities  = tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    quantities -= tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.KCS);
                                                    break;

                                                case (int)eTypeOfKeypad.TC:
                                                    quantities  = tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    quantities -= tdns.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.TC);
                                                    break;

                                                case (int)eTypeOfKeypad.BTP:
                                                    quantities  = 0;
                                                    quantities  = btps.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                                    quantities -= btps.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + listStrSetSanLuong[i] + "," + (quantities < 0 ? 0 : quantities) + ",,");
                                                    listStrProductConfig.Add(kp_Obj.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + listStrSetSanLuong[i] + "," + 0 + ",1");

                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(strListChuyen) && listMapIdSanPhamNgay.Count > 0)
                {
                    #region
                    var resultAdd = BLLMapCommoIdForDay.AddMapIdSanPhamNgay(strListChuyen.Substring(0, strListChuyen.Length - 1).Split(',').Select(x => Convert.ToInt32(x)).ToList(), listMapIdSanPhamNgay);;
                    if (resultAdd)
                    {
                        if (listStrProductConfig.Count > 0)
                        {
                            frmMainNew.listDataSendKeyPad.AddRange(listStrProductConfig);
                        }

                        if (frmMainNew.listMapIdSanPhamNgay != null)
                        {
                            var olds = frmMainNew.listMapIdSanPhamNgay.Where(x => x.MaChuyen == lineId).ToList();
                            if (olds.Count > 0)
                            {
                                foreach (var item in olds)
                                {
                                    frmMainNew.listMapIdSanPhamNgay.Remove(item);
                                }
                            }
                        }
                        else if (frmMainNew.listMapIdSanPhamNgay == null)
                        {
                            frmMainNew.listMapIdSanPhamNgay = new List <PMS.Data.MapIdSanPhamNgay>();
                        }
                        frmMainNew.listMapIdSanPhamNgay.AddRange(listMapIdSanPhamNgay);

                        // Reset lai thong tin ngay ve 0
                        if (IsResetAllToZero)
                        {
                            BLLProductivity.ResetDayInforByDate(DateTime.Now, assigns.Select(x => x.STTCHuyen_SanPham).ToList(), frmMainNew.getBTPInLineByType);
                        }
                        return(true);
                    }
                    #endregion
                }
            }
            catch (Exception)
            { }
            return(false);
        }