Beispiel #1
0
        private void tblSales_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int rw = e.RowIndex;
                int cl = e.ColumnIndex;
                if (Convert.ToString(tblSales.Rows[rw].Cells[0].Value) == string.Empty)
                {
                    return;
                }
                int saleID = Convert.ToInt32(tblSales.Rows[rw].Cells[0].Value.ToString());

                if (cl == 2)
                {
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "V_Customer")
                        {
                            MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            return;
                        }
                    }


                    int cid = Convert.ToInt32(tblSales.Rows[rw].Cells[0].Value.ToString());
                    //Customer cust=new Customer ();
                    //int cid =cust.getIdByName(custName, con);
                    using (V_Customer ms = new V_Customer(cid))
                    {
                        ms.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "! System Error. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private void tblSales_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                int rw = e.RowIndex;
                int cl = e.ColumnIndex;
                if (Convert.ToString(tblSales.Rows[rw].Cells[0].Value) == string.Empty)
                {
                    return;
                }
                int saleID = Convert.ToInt32(tblSales.Rows[rw].Cells[0].Value.ToString());


                if (cl == 6)
                {
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "View_Sales_Product")
                        {
                            MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            return;
                        }
                    }


                    View_Sales_Product vsd = new View_Sales_Product(saleID);

                    vsd.Show();
                }
                if (cl == 7)
                {
                    //MessageBox.Show("F**k you");
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "Edit_Credit")
                        {
                            MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            return;
                        }
                    }

                    if (Convert.ToString(tblSales.Rows[rw].Cells[5].Value) != string.Empty)
                    {
                        decimal credi = Convert.ToDecimal(tblSales.Rows[rw].Cells[5].Value);
                        if (credi < 0)
                        {
                            MessageBox.Show("No Credit Amount Found for This Transaction");
                            return;
                        }

                        publicSales.sales_id      = Convert.ToInt32(tblSales.Rows[rw].Cells[0].Value);
                        publicSales.customer_name = tblSales.Rows[rw].Cells[1].Value.ToString();
                        publicSales.credit        = Convert.ToDecimal(tblSales.Rows[rw].Cells[5].Value.ToString());
                        publicSales.total         = Convert.ToDecimal(tblSales.Rows[rw].Cells[2].Value.ToString());
                        publicSales.date_time     = Convert.ToDateTime(tblSales.Rows[rw].Cells[3].Value.ToString());
                        publicSales.paid          = Convert.ToDecimal(tblSales.Rows[rw].Cells[4].Value.ToString());

                        Edit_Credit ec = new Edit_Credit(this);
                        ec.Show();
                    }
                }
                else if (cl == 1)
                {
                    foreach (Form form in Application.OpenForms)
                    {
                        if (form.GetType().Name == "V_Customer")
                        {
                            MetroMessageBox.Show(this, "Form is already opened", "System Message!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                            return;
                        }
                    }


                    int cid = Convert.ToInt32(tblSales.Rows[rw].Cells[0].Value.ToString());
                    //Customer cust=new Customer ();
                    //int cid =cust.getIdByName(custName, con);
                    //Customer cust = new Customer();
                    //int cid = cust.getIdByName(custName, con);
                    using (V_Customer ms = new V_Customer(cid))
                    {
                        ms.ShowDialog();
                    }
                }
            }
            catch (Exception ex)
            {
                MetroMessageBox.Show(this, "! System Error . Code 104. " + ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }