コード例 #1
0
 private void SaveButton_Click(object sender, EventArgs e)
 {
     if (SaveButton.Text.Equals("Confirm"))
     {
         int updateQuantity = Convert.ToInt32(stockInQuantityTextBox.Text);
         item.AvailableQuantity += updateQuantity;
         stockIn.Quantity        = updateQuantity;
         _stockInManager.UpdateItem(item);
         _stockInManager.UpdateStockIn(stockIn);
         SaveButton.Text = "Save";
     }
     else
     {
         //stockIn.Date= DateTime.Now.ToString("yyyy/MM/dd");
         if (companyComboBox.Text.Equals("-Select-"))
         {
             messageLabel.Text = "Enter a company";
             return;
         }
         if (categoryComboBox.Text.Equals("-Select-"))
         {
             messageLabel.Text = "Enter a category";
             return;
         }
         if (itemComboBox.Text.Equals("-Select-"))
         {
             messageLabel.Text = "Enter an Item";
             return;
         }
         stockIn.Date   = stockInDateTimePicker.Value.ToString("yyyy-MM-dd");
         stockIn.ItemID = Convert.ToInt32(itemComboBox.SelectedValue);
         if (String.IsNullOrEmpty(stockInQuantityTextBox.Text))
         {
             messageLabel.Text = "Enter a quantity!";
             return;
         }
         stockIn.Quantity = Convert.ToInt32(stockInQuantityTextBox.Text);
         InsertStockIn(stockIn);
         //update avaiableQuantity
         item.ID   = stockIn.ItemID;
         dataTable = _stockInManager.GetItem(item);
         int currentQuantity = Convert.ToInt32(dataTable.Rows[0]["AvailableQuantity"]);
         item.AvailableQuantity = currentQuantity + stockIn.Quantity;
         _stockInManager.UpdateItem(item);
     }
     companyComboBox.Text          = "-Select-";
     categoryComboBox.Text         = "-Select-";
     itemComboBox.Text             = "-Select-";
     reorderLevelTextBox.Text      = "<View>";
     availableQuantityTextBox.Text = "<View>";
     stockInQuantityTextBox.Text   = "";
     DisplayRecords();
 }