Пример #1
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)
            {
            }
        }
Пример #2
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)
            {
            }
        }