private List <string> LoadDataNSChuyenExportToExcel(string tieuDe, string path, string fileName)
        {
            List <string> listFilePath = new List <string>();

            try
            {
                if (listChuyen != null && listChuyen.Count > 0)
                {
                    int appId = 1;
                    int.TryParse(ConfigurationManager.AppSettings["AppId"].ToString(), out appId);
                    var nx = BLLProductivity.GetProductivitiesInDay(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(), appId);
                    dtDataNSChuyenExportExcel.Rows.Clear();
                    if (nx.Count > 0)
                    {
                        DataRow row;
                        foreach (var item in nx)
                        {
                            row = dtDataNSChuyenExportExcel.NewRow();
                            row.SetField(0, item.LineName);
                            row.SetField(1, item.LaborInLine);
                            row.SetField(2, item.CommoName);
                            row.SetField(3, item.ProductionPlans);
                            row.SetField(4, item.LK_TH);
                            row.SetField(5, item.LK_BTP);
                            row.SetField(6, item.NormsOfDay);
                            row.SetField(7, item.BTP_Day);
                            row.SetField(8, item.TH_Day);
                            row.SetField(9, item.ErrorsInDay);
                            row.SetField(10, item.TH_Percent);
                            row.SetField(11, item.ErrorPercent);
                            row.SetField(12, item.BTPInLine);
                            row.SetField(13, item.Funds);
                            row.SetField(14, item.ResearchPaced);
                            row.SetField(15, item.CurrentPacedProduction);
                            row.SetField(16, item.TC_Paced);
                            row.SetField(17, item.RevenuesInDay);
                            row.SetField(18, item.RevenuesInMonth);
                            row.SetField(19, item.TC_Day);
                            row.SetField(20, item.LK_TC);
                            dtDataNSChuyenExportExcel.Rows.Add(row);
                        }
                        var result = ReportDB.ExportToExcelByDataTable(tieuDe, path, fileName, dtDataNSChuyenExportExcel);
                        if (result)
                        {
                            listFilePath.Add(path + fileName);
                        }
                        else
                        {
                            MessageBox.Show("Lỗi: Tạo file excel năng suất chuyền không thành công.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi: " + ex.Message);
            }
            return(listFilePath);
        }
示例#2
0
 private void GetNew()
 {
     try
     {
         var data = BLLProductivity.GetProductivitiesInDay(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(), frmMain.appId);
         gridControl1.DataSource = data;
     }
     catch (Exception ex)
     {
         //  frmMain.GhiFileLog(DateTime.Now + "loi GetNew form dayinfo_view ex :" + ex.Message + " \n");
     }
 }
示例#3
0
        private void GetNew()
        {
            var data = BLLProductivity.GetProductivitiesInDay(AccountSuccess.strListChuyenId.Split(',').Select(x => Convert.ToInt32(x)).ToList(), AppId);

            dgTTNangXuat.DataSource = data;
            for (int i = 0; i < data.Count; i++)
            {
                if (data[i].IsFinish)
                {
                    dgTTNangXuat.Rows[i].DefaultCellStyle.BackColor = Color.PaleVioletRed;
                }
            }
        }
示例#4
0
        /// <summary>
        /// reset keypad tinh san luong rieng theo tung keypad ko cong chung tat ca lai
        /// </summary>
        /// <param name="lineId"></param>
        /// <param name="sttChuyenSanPham"></param>
        /// <param name="errorId"></param>
        /// <param name="typeOfProduction"></param>
        /// <param name="todayStr"></param>
        /// <param name="frmMainNew"></param>
        public static void ResetKeypad_moi(int lineId, int sttChuyenSanPham, int errorId, int typeOfProduction, string todayStr, FrmMainNew frmMainNew)
        {
            try
            {
                var assigns = BLLProductivity.GetProductivitiesInDay(todayStr, lineId);
                if (assigns != null && assigns.Count > 0)
                {
                    for (int i = 0; i < assigns.Count; i++)
                    {
                        if (assigns[i].STTCHuyen_SanPham == sttChuyenSanPham)
                        {
                            var keypads = BLLKeyPad.GetKeyPadInfoByLineId(lineId);
                            if (keypads != null && keypads.Count > 0)
                            {
                                var tdns       = BLLDayInfo.GetByCommoId(sttChuyenSanPham, assigns[i].productId, frmMainNew.todayStr);
                                var btps       = BLLDayInfo.GetBTPNgay(sttChuyenSanPham, frmMainNew.todayStr);
                                int quantities = 0;
                                foreach (var keyPadInfo in keypads)
                                {
                                    if (keyPadInfo.UseTypeId == (int)eUseKeyPadType.OneKeyPadOneObject)
                                    {
                                        var slCuaKeypad = tdns.Where(x => x.EquipmentId == keyPadInfo.EquipmentId).ToList();
                                        var slBTPKeypad = btps.Where(x => x.EquipmentId == keyPadInfo.EquipmentId).ToList();

                                        // frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ClearData + ",,");
                                        switch (typeOfProduction)
                                        {
                                        case (int)eProductOutputType.KCS:
                                            if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.KCS)
                                            {
                                                quantities  = slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                quantities -= slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(c => c.ThanhPham);
                                                frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.KCS);
                                            }
                                            break;

                                        case (int)eProductOutputType.TC:
                                            if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.TC)
                                            {
                                                quantities  = slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductIncrease && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                quantities -= slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ProductReduce && c.ProductOutputTypeId == (int)eProductOutputType.TC).Sum(c => c.ThanhPham);
                                                frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.TC);
                                            }
                                            break;

                                        case (int)eProductOutputType.BTP:
                                            if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.BTP)
                                            {
                                                quantities  = slBTPKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPIncrease).Sum(c => c.BTPNgay);
                                                quantities -= slBTPKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.BTPReduce).Sum(c => c.BTPNgay);
                                                frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + ",1");
                                            }
                                            break;

                                        case (int)eProductOutputType.Error:
                                            var errorObj = BLLError.GetById(errorId);
                                            quantities  = slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorIncrease && c.ErrorId.HasValue && c.ErrorId.Value == errorId).Sum(c => c.ThanhPham);
                                            quantities -= slCuaKeypad.Where(c => c.CommandTypeId == (int)eCommandRecive.ErrorReduce && c.ErrorId.HasValue && c.ErrorId.Value == errorId).Sum(c => c.ThanhPham);
                                            frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductError + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + "," + errorObj.Code);
                                            break;
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#5
0
        /// <summary>
        /// Dong bo lai thong tin keypad cua tat cac cac cum sau khi su ly xong
        /// </summary>
        /// <param name="lineId"></param>
        /// <param name="sttChuyenSanPham"></param>
        /// <param name="errorId"></param>
        /// <param name="typeOfProduction">loai hinh nang suat KCS - TC - BTP -ERROR </param>
        /// <param name="todayStr"></param>
        /// <param name="frmMainNew"></param>
        public static void ResetKeypad(int lineId, int sttChuyenSanPham, int errorId, int typeOfProduction, string todayStr, FrmMainNew frmMainNew)
        {
            try
            {
                // frmMainNew.aaaaa = "";
                var assigns = BLLProductivity.GetProductivitiesInDay(todayStr, lineId);
                if (assigns != null && assigns.Count > 0)
                {
                    for (int i = 0; i < assigns.Count; i++)
                    {
                        if (assigns[i].STTCHuyen_SanPham == sttChuyenSanPham)
                        {
                            var keypads = BLLKeyPad.GetKeyPadInfoByLineId(lineId);
                            if (keypads != null && keypads.Count > 0)
                            {
                                var nxInDay    = BLLProductivity.GetProductivitiesInDay(DateTime.Now, sttChuyenSanPham);
                                int quantities = 0;
                                if (nxInDay != null)
                                {
                                    foreach (var keyPadInfo in keypads)
                                    {
                                        if (keyPadInfo.UseTypeId == (int)eUseKeyPadType.OneKeyPadOneObject)
                                        {
                                            // frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ClearData + ",,");
                                            switch (typeOfProduction)
                                            {
                                            case (int)eProductOutputType.KCS:
                                                if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.KCS)
                                                {
                                                    //  frmMainNew.aaaaa += " - " + keyPadInfo.EquipmentId.ToString() + "(type:" + keyPadInfo.TypeOfKeypad + ")" + "(typeOfProduction:" + typeOfProduction + ")";
                                                    quantities = (nxInDay.ThucHienNgay - nxInDay.ThucHienNgayGiam);
                                                    frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.KCS);
                                                }
                                                break;

                                            case (int)eProductOutputType.TC:
                                                if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.TC)
                                                {
                                                    // frmMainNew.aaaaa += " - " + keyPadInfo.EquipmentId.ToString() + "(type:" + keyPadInfo.TypeOfKeypad + ")" + "(typeOfProduction:" + typeOfProduction + ")";
                                                    quantities = (nxInDay.BTPThoatChuyenNgay - nxInDay.BTPThoatChuyenNgayGiam);
                                                    frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductQuantity + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + "," + (int)eProductOutputType.TC);
                                                }
                                                break;

                                            case (int)eProductOutputType.BTP:
                                                if (keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.All || keyPadInfo.TypeOfKeypad == (int)eTypeOfKeypad.BTP)
                                                {
                                                    //  frmMainNew.aaaaa += " - " + keyPadInfo.EquipmentId.ToString() + "(type:" + keyPadInfo.TypeOfKeypad + ")" + "(typeOfProduction:" + typeOfProduction + ")";
                                                    quantities = nxInDay.BTPTang - nxInDay.BTPGiam;
                                                    frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeBTPQuantities + "," + (i + 1) + "," + (quantities < 0 ? 0 : quantities) + ",1");
                                                }
                                                break;

                                            case (int)eProductOutputType.Error:
                                                var errorObj = BLLError.GetById(errorId);
                                                var err      = nxInDay.Errors.FirstOrDefault(x => x.ErrorId == errorId);
                                                frmMainNew.listDataSendKeyPad.Add(keyPadInfo.EquipmentId.ToString() + "," + (int)eCommandSend.ChangeProductError + "," + (i + 1) + "," + (err != null ? err.SoLuongTang - err.SoLuongGiam : 0) + "," + errorObj.Code);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
示例#6
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);
        }