Example #1
0
 private void grid_IdNameItem_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         SupplierDBaccess SA = new SupplierDBaccess();
         Grid_ItemType.DataSource = SA.getSupplierItems(grid_IdNameItem.CurrentRow.Cells["sup_id"].Value.ToString());
         Grid_ItemType.ClearSelection();
     }
     catch (SqlException)
     {
         MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (FormatException)
     {
         MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (OutOfMemoryException)
     {
         MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception)
     {
         MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void btn_reg_Click(object sender, EventArgs e)
 {
     try
     {
         listpanel[index = 0].BringToFront();
         //Get last record from supplier
         SupplierDBaccess SA = new SupplierDBaccess();
         txt_SupId.Text = SA.GetSupplierId();
     }
     catch (SqlException)
     {
         MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (FormatException)
     {
         MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (OutOfMemoryException)
     {
         MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception)
     {
         MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void grid_AppOdr_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         SupplierDBaccess SA    = new SupplierDBaccess();
         String           supId = grid_AppOdr.CurrentRow.Cells["sup_id"].Value.ToString();
         if (SA.getOrdrSuppliers(supId).Rows.Count != 0)
         {
             DataRow dr = SA.getOrdrSuppliers(supId).Rows[0];
             txt_OrderSupEmail.Text   = dr["sup_email"].ToString();
             txt_OrderSupContact.Text = dr["sup_cont"].ToString();
         }
     }
     catch (SqlException)
     {
         MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (FormatException)
     {
         MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (OutOfMemoryException)
     {
         MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception)
     {
         MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        public PurchaseOrderForm()
        {
            InitializeComponent();
            SupplierDBaccess SA = new SupplierDBaccess();
            DataTable        dt = SA.getAllSuppliers();

            Grid_sup.DataSource = dt;
            validateDatePiker();
        }
        private void PurchaseOrderForm_Load(object sender, EventArgs e)
        {
            try
            {
                listpanel.Add(panel_Reg);
                listpanel.Add(panel_Order);
                listpanel.Add(panel_Recieve);
                listpanel.Add(panel_display);
                listpanel.Add(Panel_AppOdr);
                listpanel.Add(panel_ConfirmSales);
                listpanel[index].BringToFront();
                listpanel[index = 3].BringToFront();

                SupplierDBaccess SA = new SupplierDBaccess();
                grid_IdNameItem.DataSource = SA.getSupplierIDNameItem();

                /*
                 * SqlDataReader sqlRed = Po.fillCmbSupName();
                 * try
                 * {
                 *    while (sqlRed.Read())
                 *    {
                 *        cmb_SupName.Items.Add(sqlRed[0] + " (" + sqlRed[1] + ")"); //Load supplier names to combo box
                 *    }
                 * }
                 * catch (Exception ex)
                 * {
                 *    MessageBox.Show("An error occurred: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 * }
                 * finally
                 * {
                 *    sqlRed.Close();
                 * } */
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_Order_Click_1(object sender, EventArgs e)
        {
            try
            {
                listpanel[index = 1].BringToFront();
                //Hide other text boxes when first time open
                txt_ItemType.Visible = false;
                txt_qty2.Visible     = false;
                btn_add2.Visible     = false;
                btn_remove2.Visible  = false;
                lb_other.Visible     = false;
                lb_Qty2.Visible      = false;
                lb_size.Visible      = false;
                lb_color.Visible     = false;
                cmb_color.Visible    = false;
                cmb_size.Visible     = false;

                //create object of SupplierDBaccess class
                SupplierDBaccess SA = new SupplierDBaccess();
                grid_IdNameItem.DataSource = SA.getSupplierIDNameItem();
                PurchaseOrderDBaccess PO = new PurchaseOrderDBaccess();
                Grid_PurchaseOrder.DataSource = PO.getAllPurchaseOrders();

                grid_IdNameItem.ClearSelection();

                txt_POno.Text = PO.GetPurId();
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #7
0
        private void btn_SupReport_Click(object sender, EventArgs e)
        {
            try
            {
                listpanel[index = 4].BringToFront();

                DateTime date = DateTime.Today.Date;

                var firstDayOfMonth = new DateTime(date.Year, date.Month, 1).AddDays(-1);
                var lastDayOfMonth  = firstDayOfMonth.AddMonths(-1).AddDays(1);


                var firstDayOfMonth1 = lastDayOfMonth.AddDays(-1);
                var lastDayOfMonth1  = firstDayOfMonth.AddMonths(-2).AddDays(1);


                lb_supFrom.Text = lastDayOfMonth.ToString("dd/MM/yyyy");
                lb_supTo.Text   = firstDayOfMonth.ToString("dd/MM/yyyy");



                SupplierDBaccess SA = new SupplierDBaccess();
                grid_IdNameItem.DataSource = SA.getAllSuppliers();
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void btn_SupReg_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(txt_SupName.Text))
                {
                    MetroMessageBox.Show(this, "\n\nPlease enter Supplier Name", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (String.IsNullOrEmpty(txt_Add.Text))
                {
                    MetroMessageBox.Show(this, "\n\nPlease enter Supplier Address", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (String.IsNullOrEmpty(txt_Email.Text))
                {
                    MetroMessageBox.Show(this, "\n\nPlease enter Supplier Email Address", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (String.IsNullOrEmpty(txt_Contact.Text))
                {
                    MetroMessageBox.Show(this, "\n\nPlease enter Supplier Contact Number", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (txt_SupName.Text.Any(Char.IsDigit))
                {
                    MetroFramework.MetroMessageBox.Show(this, "Please enter letter only for Name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (txt_Contact.Text.Any(Char.IsLetter))
                {
                    MetroFramework.MetroMessageBox.Show(this, "Cannot enter letters for contact number.enter numbers only!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (txt_Contact.Text.Length != 10)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Contact Number should be 10 digits!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (chk_But.Checked == false && chk_cut.Checked == false && chk_Lether.Checked == false && chk_sew.Checked == false)
                {
                    MetroFramework.MetroMessageBox.Show(this, "Please select at least one Item type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    Supplier supplier = new Supplier(); // new supplier object created and get values to variables
                    supplier.Sup_Id    = txt_SupId.Text.ToString();
                    supplier.Sup_Name  = txt_SupName.Text.ToString();
                    supplier.Address   = txt_Add.Text.ToString();
                    supplier.Email     = txt_Email.Text.ToString();
                    supplier.ContactNo = txt_Contact.Text.ToString();

                    SupplierItems suppItem = new SupplierItems();
                    suppItem.Sup_Id = txt_SupId.Text.ToString();

                    SupplierDBaccess SA = new SupplierDBaccess();
                    int Status          = SA.createSupplier(supplier);
                    if (Status == 1)
                    {
                        if (chk_cut.Checked)
                        {
                            suppItem.SupItem_Id = SA.GetSuppItemId();
                            suppItem.ItemType   = lb_cut.Text;
                            SA.AddSupplierItems(suppItem);
                        }
                        if (chk_sew.Checked)
                        {
                            suppItem.SupItem_Id = SA.GetSuppItemId();
                            suppItem.ItemType   = lb_sew.Text;
                            SA.AddSupplierItems(suppItem);
                        }
                        if (chk_But.Checked)
                        {
                            suppItem.SupItem_Id = SA.GetSuppItemId();
                            suppItem.ItemType   = lb_But.Text;
                            SA.AddSupplierItems(suppItem);
                        }
                        if (chk_Lether.Checked)
                        {
                            suppItem.SupItem_Id = SA.GetSuppItemId();
                            suppItem.ItemType   = lb_Lether.Text;
                            SA.AddSupplierItems(suppItem);
                        }
                        MetroMessageBox.Show(this, "\n\nYou were registerd succesfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txt_SupName.Clear();
                        txt_Add.Clear();
                        txt_Email.Clear();
                        txt_Contact.Clear();
                        chk_But.Checked    = false;
                        chk_cut.Checked    = false;
                        chk_Lether.Checked = false;
                        chk_sew.Checked    = false;
                    }
                    else
                    {
                        MetroMessageBox.Show(this, "\n\nRegistation Fail", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }



                    DataTable dt = SA.getAllSuppliers();
                    Grid_sup.DataSource = dt;

                    txt_SupId.Text = SA.GetSupplierId();
                }
            }
            catch (SqlException)
            {
                MetroMessageBox.Show(this, "\n\nConnecton Failed", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (FormatException)
            {
                MetroMessageBox.Show(this, "\n\nInvalid Format", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (OutOfMemoryException)
            {
                MetroMessageBox.Show(this, "\n\nInsuffisent memory", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception)
            {
                MetroMessageBox.Show(this, "\n\nERROR", "Fail", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }