예제 #1
0
 private void btnAddProduct_Click(object sender, EventArgs e)
 {
     try
     {
         AddPurchaseProductForm form = new AddPurchaseProductForm(SupplierId, PurchaseOrderId, null, true);
         form.ShowDialog();
         if (form.PurchaseOrderId > 0)
         {
             PurchaseOrderId = form.PurchaseOrderId;
             LoadProductList(PurchaseOrderId);
             VisibleControls();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private void grdMetroProduct_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (grdMetroProduct.RowCount > 0)
                {
                    if (e.RowIndex >= 0)
                    {
                        int             Id;
                        DataGridViewRow row = grdMetroProduct.Rows[e.RowIndex];

                        if (grdMetroProduct.Columns[e.ColumnIndex].Name == "View/Edit")
                        {
                            Id = System.Convert.ToInt32(row.Cells["PurchaseProductId"].Value.ToString());
                            AddPurchaseProductForm form = new AddPurchaseProductForm(SupplierId, PurchaseOrderId, Id, false);
                            form.ShowDialog();
                            if (!form.IsCancelUpdate)
                            {
                                LoadProductList(PurchaseOrderId);
                            }
                        }
                        else if (grdMetroProduct.Columns[e.ColumnIndex].Name == "Delete")
                        {
                            if (MessageBox.Show("Are you sure do you want to delete this product?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                            {
                                Id = System.Convert.ToInt32(row.Cells["PurchaseProductId"].Value.ToString());
                                using (InventoryDataContext context = new InventoryDataContext())
                                {
                                    PurchaseManager manager = new PurchaseManager();
                                    manager.DeletePurchaseProductById(context, Id);
                                }
                                LoadProductList(PurchaseOrderId);
                            }
                        }
                        else if (grdMetroProduct.Columns[e.ColumnIndex].Name == "Change Status")
                        {
                            int    pOrderId = System.Convert.ToInt32(row.Cells["PurchaseOrderId"].Value.ToString());
                            int    pId      = System.Convert.ToInt32(row.Cells["PurchaseProductId"].Value.ToString());
                            string status   = row.Cells["PurchaseProductStatus"].Value.ToString();
                            string remarks  = row.Cells["Remarks"].Value.ToString();
                            PurchaseProductStatusForm form = new PurchaseProductStatusForm(pOrderId, pId, status, remarks);
                            form.ShowDialog();
                            if (!form.IsCancelUpdate)
                            {
                                using (InventoryDataContext context = new InventoryDataContext())
                                {
                                    PurchaseManager            manager = new PurchaseManager();
                                    GetPurchaseOrderByIdResult obj     = new GetPurchaseOrderByIdResult();
                                    obj = manager.GetPurchaseOrderById(context, PurchaseOrderId).Single();
                                    PurchaseOrderStatusId  = obj.PurchaseOrderStatusId;
                                    txtBoxMetroStatus.Text = obj.PurchaseOrderStatus.ToString();
                                    AreAllItemsReceived    = form.AreAllItemsReceived;
                                    LoadProductList(PurchaseOrderId);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }