Пример #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (((int)cbbTransactionType.SelectedValue == 1 && cbbSuppliers.SelectedIndex == -1) || ((int)cbbTransactionType.SelectedValue == 2 && cbbSourceWarehouse.SelectedIndex == -1) || txtAmount.Text == "")
     {
         lbWarning.Text = "Please enter information!";
     }
     else
     {
         if ((int)cbbTransactionType.SelectedValue == 2 && ((int)cbbSourceWarehouse.SelectedValue == (int)cbbDestinationWarehouse.SelectedValue))
         {
             lbWarning.Text = "Source and the Destination Warehouses can't be the same";
         }
         else
         {
             float R = XuLy.getReceivedAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, txtBatchNumber.Text);
             float T = XuLy.getTransferredAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, txtBatchNumber.Text);
             if (R - T - int.Parse(txtAmount.Text) + Program.oldEdit.Amount < 0)
             {
                 MessageBox.Show("Max amount remain: " + (R - T), "");
             }
             else
             {
                 InventoryManagementView viewOld = Program.oldEdit;
                 InventoryManagementView viewNew = new InventoryManagementView();
                 viewNew.TransactionTypeID = (int)cbbTransactionType.SelectedValue;
                 if ((int)cbbTransactionType.SelectedValue == 1)
                 {
                     viewNew.SupplierID = (int)cbbSuppliers.SelectedValue;
                 }
                 else
                 {
                     viewNew.SourceWarehouseID = (int)cbbSourceWarehouse.SelectedValue;
                 }
                 viewNew.DestinationWarehouseID = (int)cbbDestinationWarehouse.SelectedValue;
                 viewNew.PartID       = (int)cbbPartName.SelectedValue;
                 viewNew.Amount       = int.Parse(txtAmount.Text);
                 viewNew.Date         = dtpDate.Value;
                 viewNew.OrderID      = viewOld.OrderID;
                 viewNew.OrderItemsID = viewOld.OrderItemsID;
                 XuLy.EditInventoryManagement(viewNew);
                 this.Close();
                 Program.list = XuLy.getInventoryManagementView();
                 Program.f.viewInventoryTable(Program.list);
                 Program.f.dgv1.ClearSelection();
                 for (int i = 0; i < Program.list.Count; i++)
                 {
                     if (Program.list[i].OrderItemsID == viewNew.OrderItemsID)
                     {
                         Program.f.dgv1.Rows[i].Selected = true;
                         break;
                     }
                 }
             }
         }
     }
 }
Пример #2
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (list.Count == 0)
     {
         lbWarning.Text = "Empty Part";
     }
     else
     {
         if ((int)cbbSourceWarehouse.SelectedValue == (int)cbbDestinationWarehouse.SelectedValue)
         {
             lbWarning.Text = "Source and the Destination Warehouses can't be the same";
         }
         else
         {
             bool validAmount = true;
             for (int i = 0; i < list.Count; i++)
             {
                 float R = XuLy.getReceivedAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, cbbBatchNumber.Enabled == true ? cbbBatchNumber.SelectedValue.ToString() : "");
                 float T = XuLy.getTransferredAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, cbbBatchNumber.Enabled == true ? cbbBatchNumber.SelectedValue.ToString() : "");
                 if (R - T - list[i].Amount < 0)
                 {
                     MessageBox.Show("Max amount of " + list[i].PartName + " [" + list[i].BatchNumber + "]" + ": " + (R - T), "");
                     validAmount = false;
                     viewDGV();
                     dgvWarehouseManagement.ClearSelection();
                     dgvWarehouseManagement.Rows[i].Selected = true;
                     break;
                 }
             }
             if (!validAmount)
             {
             }
             else
             {
                 XuLy.addWarehouseManagement(2, (int)cbbSourceWarehouse.SelectedValue, (int)cbbDestinationWarehouse.SelectedValue, dtpDate.Value, list);
                 form f = new form();
                 f.Show();
                 Program.list = XuLy.getInventoryManagementView();
                 Program.f.viewInventoryTable(Program.list);
                 lbWarning.Text = "";
                 this.Close();
             }
         }
     }
 }