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)dgOutsoleMaterial.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)
                    {
                        OutsoleOutputModel model = new OutsoleOutputModel
                        {
                            ProductNo = productNo,
                            SizeNo    = sizeNo,
                            Quantity  = quantity,
                        };
                        outsoleOutputToInsertList.Add(model);
                    }
                }

                if (qtyActual > 0 && outsoleActualStartDateAuto == "")
                {
                    outsoleActualStartDateAuto = String.Format("{0:M/d}", nowDate);
                }
                outsoleActualFinishDateAuto = "";
                if (qtyActual >= sizeRunList.Sum(s => s.Quantity) && outsoleActualFinishDateAuto == "")
                {
                    outsoleActualFinishDateAuto = String.Format("{0:M/d}", nowDate);
                }
            }
            if (bwInsert.IsBusy == false)
            {
                this.Cursor       = Cursors.Wait;
                btnSave.IsEnabled = false;
                bwInsert.RunWorkerAsync();
            }
        }
Exemple #2
0
        public static bool Insert(OutsoleOutputModel model)
        {
            var @ProductNo = new SqlParameter("@ProductNo", model.ProductNo);
            var @SizeNo    = new SqlParameter("@SizeNo", model.SizeNo);
            var @Quantity  = new SqlParameter("@Quantity", model.Quantity);

            SaovietMasterScheduleEntities db = new SaovietMasterScheduleEntities();

            if (db.ExecuteStoreCommand("EXEC spm_InsertOutsoleOutput @ProductNo,@SizeNo,@Quantity", @ProductNo, @SizeNo, @Quantity) >= 1)
            {
                return(true);
            }
            return(false);
        }