Example #1
0
        public static bool Insert(SockliningInputModel model)
        {
            var @ProductNo = new SqlParameter("@ProductNo", model.ProductNo);
            var @SizeNo    = new SqlParameter("@SizeNo", model.SizeNo);
            var @Quantity  = new SqlParameter("@Quantity", model.Quantity);

            using (var db = new SaovietMasterScheduleEntities())
            {
                if (db.ExecuteStoreCommand("EXEC spm_InsertSockliningInput @ProductNo, @SizeNo, @Quantity", @ProductNo, @SizeNo, @Quantity) > 0)
                {
                    return(true);
                }
                return(false);
            };
        }
        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Confirm Save?", this.Title, MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.No)
            {
                return;
            }
            // get date
            nowDate = DateTime.Now.Date.AddDays(-1);
            while (offDayList.Select(s => s.Date).ToList().Contains(nowDate))
            {
                nowDate = nowDate.AddDays(-1);
            }
            dt = ((DataView)dgSockliningInput.ItemsSource).ToTable();
            foreach (DataRow dr in dt.Rows)
            {
                int qtyActual = 0;
                for (int i = 0; i <= sizeRunList.Count - 1; i++)
                {
                    string sizeNo   = sizeRunList[i].SizeNo;
                    int    quantity = (Int32)dr[String.Format("Column{0}", i)];
                    qtyActual += quantity;
                    if (quantity >= 0)
                    {
                        var model = new SockliningInputModel
                        {
                            ProductNo = productNo,
                            SizeNo    = sizeNo,
                            Quantity  = quantity,
                        };
                        sockliningInputInsertList.Add(model);
                    }
                }
            }

            if (bwInsert.IsBusy == false)
            {
                this.Cursor       = Cursors.Wait;
                btnSave.IsEnabled = false;
                bwInsert.RunWorkerAsync();
            }
        }