private void btnUpdateToDataBase_Click(object sender, EventArgs e)
 {
     try
     {
         if (MessageBox.Show("Update to DataBase?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             using (InventoryDataContext context = new InventoryDataContext())
             {
                 PurchaseManager manager = new PurchaseManager();
                 IsUpdatedToDB = System.Convert.ToBoolean(manager.UpdatePurchaseProductToDB(context, PurchaseOrderId, Global.UserIdToken));
                 if (IsUpdatedToDB)
                 {
                     grdMetroProduct.Columns.Remove("View/Edit");
                     grdMetroProduct.Columns.Remove("Change Status");
                     VisibleControls();
                     MessageBox.Show("Update to Inventory was successful..");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         using (InventoryDataContext context = new InventoryDataContext())
         {
             if (MessageBox.Show("Submit Order?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
             {
                 PurchaseManager manager = new PurchaseManager();
                 manager.SubmitPurchaseOrder(context, PurchaseOrderId);
                 PurchaseOrderStatusId  = (int)Constants.PurchaseOrderStatus.Submitted;
                 txtBoxMetroStatus.Text = Constants.PurchaseOrderStatus.Submitted.ToString();
                 grdMetroProduct.Columns.Remove("Delete");
                 grdMetroProduct.Columns.Remove("View/Edit");
                 AddChangeStatusLinkOnGrid();
                 LoadProductList(PurchaseOrderId);
                 VisibleControls();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #3
0
        public ActionResult Edit(Category newcat)
        {
            InventoryDataContext ctx = new InventoryDataContext();

            try
            {
                var cat = (from c in ctx.Categories
                           where c.Code == newcat.Code
                           select c).SingleOrDefault();

                if (cat != null)
                {
                    cat.Description = newcat.Description;
                    ctx.SubmitChanges();
                }
                else
                {
                    TempData["message"] = "Sorry! Could not find category!";
                }
            }
            catch (Exception ex)
            {
                TempData["message"] = "Sorry! Could not update category!";
            }
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public ActionResult Delete(string id)
        {
            InventoryDataContext ctx = new InventoryDataContext();
            var cat = (from c in ctx.Categories
                       where c.Code == id
                       select c).SingleOrDefault();

            if (cat != null)
            {
                try {
                    ctx.Categories.DeleteOnSubmit(cat);
                    ctx.SubmitChanges();
                    TempData["message"] = "Deleted Category [" + id + "]";
                }
                catch (Exception ex)
                {
                    TempData["message"] = "Error : " + ex.Message;
                }
            }
            else
            {
                TempData["message"] = "Category [" + id + "] Not Found!";
            }

            return(RedirectToAction("Index"));
        }
Exemple #5
0
        private void btnLoadReport_Click(object sender, EventArgs e)
        {
            try
            {
                using (InventoryDataContext context = new InventoryDataContext())
                {
                    GetSalesReportByDateResultBindingSource.DataSource = context.GetSalesReportByDate(dateFrom.Value, dateTo.Value);

                    GetSalesSumReportByDateResult obj = new GetSalesSumReportByDateResult();
                    obj = context.GetSalesSumReportByDate(dateFrom.Value, dateTo.Value).Single();

                    Microsoft.Reporting.WinForms.ReportParameter[] rParams = new Microsoft.Reporting.WinForms.ReportParameter[]
                    {
                        new Microsoft.Reporting.WinForms.ReportParameter("retailSale", obj.RetaiSale.ToString()),
                        new Microsoft.Reporting.WinForms.ReportParameter("wholeSale", obj.WholeSale.ToString()),
                        new Microsoft.Reporting.WinForms.ReportParameter("profit", obj.Profit.ToString())
                    };
                    rptSalesReport.LocalReport.SetParameters(rParams);
                    rptSalesReport.RefreshReport();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void PurchasingDetailsForm_Load(object sender, EventArgs e)
        {
            try
            {
                FormBorderStyle = FormBorderStyle.None;
                WindowState     = FormWindowState.Maximized;
                TopMost         = false;

                using (InventoryDataContext context = new InventoryDataContext())
                {
                    GetPurchaseOrderByIdResult obj     = new GetPurchaseOrderByIdResult();
                    PurchaseManager            manager = new PurchaseManager();
                    obj = manager.GetPurchaseOrderById(context, PurchaseOrderId).Single();

                    txtBoxMetroSupplierName.Text = obj.SupplierName;
                    txtBoxMetroStatus.Text       = obj.PurchaseOrderStatus;
                    txtBoxMetroOrderNumber.Text  = obj.PurchaseOrderId.ToString();

                    PurchaseOrderId       = obj.PurchaseOrderId;
                    PurchaseOrderStatusId = obj.PurchaseOrderStatusId;
                    SupplierId            = obj.SupplierId;
                    IsUpdatedToDB         = obj.IsUpdatedToDB;

                    if (obj.CustomerId != null)
                    {
                        CustomerId = (int)obj.CustomerId;
                        txtBoxMetroCustomerName.Text = obj.LastName + ", " + obj.FirstName;
                    }
                    if (obj.OrderDate != null)
                    {
                        dateTimeMetroOrderDate.Value = System.Convert.ToDateTime(obj.OrderDate);
                    }
                    txtBoxMetroTotalAmount.Text = obj.TotalAmount.ToString();

                    if (!IsAddMode)
                    {
                        AreAllItemsReceived = System.Convert.ToBoolean(manager.CheckPurchaseProductIfReceived(context, PurchaseOrderId));
                    }
                }

                if (!IsAddMode)
                {
                    LoadProductList(PurchaseOrderId);
                    AddDynamicLinkOnGrid(grdMetroProduct, 13, 14);
                    EnableHideColumnGrid();
                }
                else
                {
                    VisibleControls();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void LoadProductList(int purchaseOrderId)
        {
            using (InventoryDataContext context = new InventoryDataContext())
            {
                PurchaseManager manager = new PurchaseManager();

                grdMetroProduct.DataSource            = manager.GetPurchaseProductList(context, purchaseOrderId);
                grdMetroProduct.Columns[3].HeaderText = "Status";

                VisibleControls();
            }
        }
Exemple #8
0
        public ActionResult Edit(string id)
        {
            InventoryDataContext ctx = new InventoryDataContext();
            var cat = (from c in ctx.Categories
                       where c.Code == id
                       select c).SingleOrDefault();

            if (cat != null)
            {
                return(View(cat));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemple #9
0
        public ActionResult Create(Category cat)
        {
            InventoryDataContext ctx = new InventoryDataContext();

            try {
                ctx.Categories.InsertOnSubmit(cat);
                ctx.SubmitChanges();
                ViewBag.Message = "Category Added Successfully!";
                cat             = new Category();
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Sorry! Could not add category!";
            }
            return(View(cat));
        }
        public ActionResult Create()
        {
            // create collection of SelectListItem
            InventoryDataContext  dc    = new InventoryDataContext();
            List <SelectListItem> items = new List <SelectListItem>();

            foreach (Product p in dc.Products)
            {
                items.Add(new SelectListItem {
                    Text = p.Name, Value = p.Id.ToString()
                });
            }
            ViewBag.Products = items;

            Sale s = new Sale();

            s.TransDate = DateTime.Today.ToString("dd-MM-yyyy");
            return(View(s));
        }
 private void btnSaveOrderDetails_Click(object sender, EventArgs e)
 {
     try
     {
         using (InventoryDataContext context = new InventoryDataContext())
         {
             int?_customerId = null;
             if (CustomerId > 0)
             {
                 _customerId = CustomerId;
             }
             PurchaseManager manager = new PurchaseManager();
             manager.UpdatePurchaseOrder(context, PurchaseOrderId, _customerId, dateTimeMetroOrderDate.Value, System.Convert.ToDecimal(txtBoxMetroTotalAmount.Text));
             MessageBox.Show("Save Successfully");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void lnlkLabelCustomerName_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         CustomerForm form = new CustomerForm();
         form.IsFromPurchaseForm = true;
         form.ShowDialog();
         if (form.PurchaseForCustomerId > 0)
         {
             using (InventoryDataContext context = new InventoryDataContext())
             {
                 CustomerId = form.PurchaseForCustomerId;
                 CustomerManager       manager = new CustomerManager();
                 GetCustomerByIdResult obj     = new GetCustomerByIdResult();
                 obj = manager.GetCustomerById(context, CustomerId).Single();
                 txtBoxMetroCustomerName.Text = obj.LastName + ", " + obj.FirstName;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemple #13
0
        // GET: Category
        public ActionResult Index()
        {
            InventoryDataContext ctx = new InventoryDataContext();

            return(View(ctx.Categories));
        }
        // GET: Sales
        public ActionResult Index()
        {
            InventoryDataContext dc = new InventoryDataContext();

            return(View(dc.Sales));
        }
Exemple #15
0
        // GET: Linq
        public ActionResult Index()
        {
            InventoryDataContext ctx = new InventoryDataContext();

            return(View(ctx.Products));
        }
Exemple #16
0
 public ItemController(IHostingEnvironment environment, InventoryDataContext context)
 {
     _context     = context;
     _environment = environment ?? throw new ArgumentNullException(nameof(environment));
 }
        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);
            }
        }
 public Repository()
 {
     this.context = new InventoryDataContext();
 }
 public ChemicalController(InventoryDataContext context)
 {
     _context = context;
 }
Exemple #20
0
 public InventoryRepository(InventoryDataContext context)
 {
     _context = context;
 }