예제 #1
0
파일: SupplyForm.cs 프로젝트: Auxistus/STO
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!Validation.IsAllValid(Detail.Controls))
            {
                return;
            }

            using (var repository = new SupplyRepository())
            {
                if (supplyID > 0)
                {
                    var supply = repository.GetSupply(supplyID);

                    supply.Delivered    = DeliveredDatePicker.Value.Date;
                    supply.SupplierName = SupplierNameTextBox.Text;
                    supply.Description  = DescriptionTextBox.Text;

                    repository.UpdateSupply(supply);
                    repository.Commit();

                    supplyID = supply.ID;
                }
                else
                {
                    var supply = new Supply
                    {
                        ID           = (int)IDTextBox.Text.AsInt(),
                        Delivered    = DeliveredDatePicker.Value.Date,
                        SupplierName = SupplierNameTextBox.Text,
                        Description  = DescriptionTextBox.Text
                    };

                    repository.InsertSupply(supply);
                    repository.Commit();

                    supplyID = supply.ID;
                }
            }

            ViewSupplyDetailTab(supplyID, false);
        }
예제 #2
0
파일: SupplyForm.cs 프로젝트: Auxistus/STO
        private void RemoveSupplyItemButton_Click(object sender, EventArgs e)
        {
            var supplyItemOrders = SupplyItemGrid.SelectedRows.Cast <DataGridViewRow>()
                                   .Select(x => (short)x.Cells[SupplyItemGrid_Order.Name].Value.AsShort())
                                   .ToList();

            using (var repository = new SupplyRepository())
            {
                repository.RemoveSupplyItems(supplyID, supplyItemOrders);
                repository.Commit();
            }

            ViewSupplyDetailTab(supplyID, true);
        }
예제 #3
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            var componentIDs = ComponentGrid.SelectedRows.Cast <DataGridViewRow>()
                               .Select(x => (int)x.Cells[ComponentGrid_ID.Name].Value.AsInt())
                               .ToList();

            using (var repository = new SupplyRepository())
            {
                repository.AddSupplyItems(supplyID, componentIDs);
                repository.Commit();
            }

            Close();
        }
예제 #4
0
파일: SupplyForm.cs 프로젝트: Auxistus/STO
        private void SaveSupplyItemButton_Click(object sender, EventArgs e)
        {
            foreach (DataGridViewRow row in SupplyItemGrid.Rows)
            {
                short order = (short)row.Cells[SupplyItemGrid_Order.Name].Value.AsShort();

                using (var repository = new SupplyRepository())
                {
                    var supplyItem = repository.GetSupplyItem(supplyID, order);

                    supplyItem.Quantity = (int)row.Cells[SupplyItemGrid_Quantity.Name].Value.AsInt();

                    repository.UpdateSupplyItem(supplyItem);
                    repository.Commit();
                }
            }

            ViewSupplyDetailTab(supplyID, true);
        }
예제 #5
0
파일: SupplyForm.cs 프로젝트: Auxistus/STO
        private void ApproveButton_Click(object sender, EventArgs e)
        {
            DialogResult result;

            if (IsSupplyItemChanged)
            {
                result = MessageBox.Show(Resources.SupplyApproveUnsavedItemsText.FormatWith(supplyID), Resources.SupplyApproveConfirmationCaption, MessageBoxButtons.YesNoCancel);

                switch (result)
                {
                case DialogResult.Yes:
                    SaveSupplyItemButton_Click(sender, e);
                    break;

                case DialogResult.Cancel:
                    return;
                }
            }
            else
            {
                result = MessageBox.Show(Resources.SupplyApproveConfirmationText.FormatWith(supplyID), Resources.SupplyApproveConfirmationCaption, MessageBoxButtons.YesNo);

                if (result == DialogResult.No)
                {
                    return;
                }
            }

            using (var repository = new SupplyRepository())
            {
                repository.ApproveSupply(supplyID);
                repository.CalculateComponentStockQuantity(supplyID);
                repository.Commit();
            }

            ViewSupplyDetailTab(supplyID, true);
        }