Exemplo n.º 1
0
        public static bool Insert(OutsoleMaterialCheckingModel model)
        {
            var @WorkerId          = new SqlParameter("@WorkerId", model.WorkerId);
            var @ProductNo         = new SqlParameter("@ProductNo", model.ProductNo);
            var @CheckingDate      = new SqlParameter("@CheckingDate", model.CheckingDate);
            var @OutsoleSupplierId = new SqlParameter("@OutsoleSupplierId", model.OutsoleSupplierId);
            var @SizeNo            = new SqlParameter("@SizeNo", model.SizeNo);
            var @Quantity          = new SqlParameter("@Quantity", model.Quantity);
            var @Reject            = new SqlParameter("@Reject", model.Reject);
            var @ErrorId           = new SqlParameter("@ErrorId", model.ErrorId);
            var @Excess            = new SqlParameter("@Excess", model.Excess);
            var @WorkingCard       = new SqlParameter("@WorkingCard", model.WorkingCard);
            var @ReturnReject      = new SqlParameter("@ReturnReject", model.ReturnReject);
            var @ReturnRemark      = new SqlParameter("@ReturnRemark", model.ReturnRemark);

            //var @SizeNoUpper        = new SqlParameter("@SizeNoUpper", model.SizeNoUpper);

            using (var db = new SaovietMasterScheduleEntities())
            {
                if (db.ExecuteStoreCommand("EXEC spm_InsertOutsoleMaterialChecking_4    @WorkerId, @ProductNo, @CheckingDate, @OutsoleSupplierId, @SizeNo, @Quantity, @Reject, @ErrorId, @Excess, @WorkingCard, @ReturnReject, @ReturnRemark",
                                           @WorkerId, @ProductNo, @CheckingDate, @OutsoleSupplierId, @SizeNo, @Quantity, @Reject, @ErrorId, @Excess, @WorkingCard, @ReturnReject, @ReturnRemark) > 0)
                {
                    return(true);
                }
                return(false);
            };
        }
Exemplo n.º 2
0
        public static bool updateBorrow(OutsoleMaterialCheckingModel model)
        {
            var @OSCheckingId    = new SqlParameter("@OSCheckingId", model.OSCheckingId);
            var @ProductNoBorrow = new SqlParameter("@ProductNoBorrow", model.ProductNoBorrow);
            var @QuantityBorrow  = new SqlParameter("@QuantityBorrow", model.QuantityBorrow);

            using (var db = new SaovietMasterScheduleEntities())
            {
                if (db.ExecuteStoreCommand("EXEC spm_UpdateOSWHBorrow @OSCheckingId, @ProductNoBorrow, @QuantityBorrow",
                                           @OSCheckingId, @ProductNoBorrow, @QuantityBorrow) > 0)
                {
                    return(true);
                }
                return(false);
            };
        }
Exemplo n.º 3
0
        private void InsertModel(int workingCart)
        {
            int qty = 0, reject = 0, returnReject = 0, returnRemark = 0;

            if (modeReturnReject == true)
            {
                returnReject = qtyInputted;
                Int32.TryParse(txtReturnRemark.Text.Trim().ToString(), out returnRemark);
            }
            else
            {
                if (modeReject == true)
                {
                    reject = qtyInputted;
                }
                else
                {
                    qty = qtyInputted;
                }
            }

            var osmCheckCurrent = new OutsoleMaterialCheckingModel
            {
                ProductNo          = poSearch,
                WorkerId           = workerId,
                CheckingDate       = checkingDate,
                OutsoleSupplierId  = supplierClicked.OutsoleSupplierId,
                SizeNo             = sizeNoInputted,
                Quantity           = qty,
                Reject             = reject,
                ReturnReject       = returnReject,
                ReturnRemark       = returnRemark,
                ErrorId            = errorPressed.ErrorID,
                WorkingCard        = workingCart,
                UpdateReject       = modeReject,
                UpdateQuantity     = !modeReject,
                UpdateReturnReject = modeReturnReject
            };

            if (bwInsert.IsBusy == false)
            {
                var tempValidateList = currentOSMCheckListBySupp.ToList();
                tempValidateList.Add(osmCheckCurrent);

                // Case Input or Reject
                if (modeReject == false && modeReturnReject == false)
                {
                    osmCheckCurrent.Quantity = tempValidateList.Where(w => w.SizeNo == osmCheckCurrent.SizeNo &&
                                                                      w.CheckingDate == osmCheckCurrent.CheckingDate &&
                                                                      w.WorkingCard == osmCheckCurrent.WorkingCard).Sum(s => s.Quantity);
                    if (MessageBox.Show(string.Format("Confirm add(update) record ?\n Size  : {0}\n Qty   : {1}\n Working Cart(Index No): {2}", osmCheckCurrent.SizeNo, osmCheckCurrent.Quantity, osmCheckCurrent.WorkingCard), this.Title, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                    {
                        txtSizeNo.Focus();
                        txtSizeNo.SelectAll();
                        return;
                    }
                    if (osmCheckCurrent.Quantity < 0)
                    {
                        MessageBox.Show("Quantity cannot be < 0 !", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                        txtQuantity.Focus();
                        txtQuantity.SelectAll();
                        return;
                    }
                }
                else if (modeReject == true && modeReturnReject == false)
                {
                    osmCheckCurrent.Reject = tempValidateList.Where(w => w.SizeNo == osmCheckCurrent.SizeNo &&
                                                                    w.CheckingDate == osmCheckCurrent.CheckingDate &&
                                                                    w.WorkingCard == osmCheckCurrent.WorkingCard &&
                                                                    w.ErrorId == osmCheckCurrent.ErrorId).Sum(s => s.Reject);
                    if (MessageBox.Show(string.Format("Confirm add(update) record ?\nSize     : {0}\nQty      : {1}\nReject  : {2} - {3}", osmCheckCurrent.SizeNo, osmCheckCurrent.Reject, errorPressed.ErrorName, errorPressed.ErrorVietNamese), this.Title, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                    {
                        txtSizeNo.Focus();
                        txtSizeNo.SelectAll();
                        return;
                    }
                    if (osmCheckCurrent.Reject < 0)
                    {
                        MessageBox.Show("Reject cannot be < 0 !\nHàng phế < 0 !", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                        txtQuantity.Focus();
                        txtQuantity.SelectAll();
                        return;
                    }
                }

                // Case Return Reject
                if (modeReturnReject == true)
                {
                    osmCheckCurrent.ReturnReject = tempValidateList.Where(w => w.SizeNo == osmCheckCurrent.SizeNo &&
                                                                          w.CheckingDate == osmCheckCurrent.CheckingDate &&
                                                                          w.WorkingCard == osmCheckCurrent.WorkingCard).Sum(s => s.ReturnReject);
                    if (osmCheckCurrent.ReturnReject < 0)
                    {
                        MessageBox.Show("Return Reject cannot be < 0 !", this.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                        txtQuantity.Focus();
                        txtQuantity.SelectAll();
                        return;
                    }

                    if (MessageBox.Show(string.Format("Confirm add (update) record ?\nSize                   : {0}\nQtyReturn OK  : {1}\nQtyRemark       : {2}",
                                                      osmCheckCurrent.SizeNo,
                                                      osmCheckCurrent.ReturnReject,
                                                      osmCheckCurrent.ReturnRemark), this.Title, MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
                    {
                        txtSizeNo.Focus();
                        txtSizeNo.SelectAll();
                        return;
                    }
                }

                this.Cursor           = Cursors.Wait;
                txtQuantity.IsEnabled = false;
                txtSizeNo.IsEnabled   = false;

                currentOSMCheckListBySupp.Add(osmCheckCurrent);
                object[] par = new object[] { osmCheckCurrent, currentOSMCheckListBySupp };
                bwInsert.RunWorkerAsync(par);
            }
        }