Example #1
0
        private void newuserform_Load(object sender, EventArgs e)
        {
            try
            {
                dbconnection db = new dbconnection();

                string query33 = "select userid from lastthings;";

                db.openconnection();
                db.command(query33);

                int olduid = 0;
                while (db.readdata().Read())
                {
                    olduid = db.readdata().GetInt32("userid");
                }
                int z = olduid + 1;
                text_uid.Text = z.ToString();

                db.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #2
0
        public void newitem_window_Load(object sender, EventArgs e)
        {
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dataGridView1.BackgroundColor = Color.WhiteSmoke;

            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView1.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
            dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
            dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;

            dbconnection gh = new dbconnection();

            gh.openconnection();
            string query20 = "select * from lastthings;";

            gh.command(query20);
            int lastpid = 0;

            while (gh.readdata().Read())
            {
                lastpid = gh.readdata().GetInt32("productid");
            }
            int sum = lastpid + 1;

            productid_label.Text = sum.ToString();
        }
Example #3
0
        private void combo_add_item_SelectedIndexChanged(object sender, EventArgs e)
        {
            string selecting = combo_add_item.Text;

            try
            {
                dbconnection dv      = new dbconnection();
                string       query10 = "select * from stock where productname='" + selecting + "';";
                dv.openconnection();
                dv.command(query10);

                int qty = 0;

                while (dv.readdata().Read())
                {
                    qty = dv.readdata().GetInt32("quantity");
                }


                add_availble.Text = qty.ToString();
                dv.closeconnection();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #4
0
        public void supplierdatagrid()
        {
            try
            {
                dbconnection ab      = new dbconnection();
                string       query25 = "select supplierid as 'Supplier ID',suppliername as 'Supplier Name',supplieraddress as 'Address', suppliertel as 'Tel/Mobile', supplieremail as 'E-mail Adrress' from pharmacy.suppliers ;";

                ab.openconnection();
                ab.command(query25);

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = ab.command(query25);
                DataTable abc = new DataTable();
                sda.Fill(abc);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = abc;
                dataGridView1.DataSource = bsourse;
                sda.Update(abc);


                dataGridView1.BorderStyle = BorderStyle.None;
                dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
                dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
                dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
                dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
                dataGridView1.BackgroundColor = Color.WhiteSmoke;

                dataGridView1.EnableHeadersVisualStyles = false;
                dataGridView1.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
                dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
                dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;

                ab.closeconnection();

                ab.openconnection();
                string query26 = "select * from lastthings;";
                ab.command(query26);


                while (ab.readdata().Read())
                {
                    pidpid = ab.readdata().GetInt32("supplierid");
                }

                label_supplierid.Text = (pidpid + 1).ToString();
                ab.closeconnection();
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #5
0
        private void bunifuThinButton24_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in dataGridView1.SelectedRows)
                {
                    dataGridView1.Rows.RemoveAt(row.Index);
                }

                if (dataGridView1.Rows.Count == 0)
                {
                    newitem_window_Load(sender, e);
                }
                else
                {
                    dbconnection ac = new dbconnection();

                    ac.openconnection();
                    string query21 = "select * from lastthings;";
                    ac.command(query21);
                    int pid = 0;

                    while (ac.readdata().Read())
                    {
                        pid = ac.readdata().GetInt32("productid");
                    }

                    int rownum = dataGridView1.Rows.Count - 1;

                    for (int i = 0; i < rownum + 1; i++)
                    {
                        pid = pid + 1;
                        string pids = pid.ToString();
                        dataGridView1.Rows[i].Cells[0].Value = pids;
                    }

                    int    rowc   = dataGridView1.Rows.Count - 1;
                    string xyz    = dataGridView1.Rows[rowc].Cells[0].Value.ToString();
                    int    newpid = Int32.Parse(xyz) + 1;
                    productid_label.Text = newpid.ToString();

                    text_newproductname.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #6
0
        void Fillcombo()
        {
            string query19 = "select * from suppliers;";

            dbconnection ab = new dbconnection();

            ab.openconnection();
            ab.command(query19);

            while (ab.readdata().Read())
            {
                string word = ab.readdata().GetString("suppliername");
                combo_supplier.Items.Add(word);
            }
        }
        public void combo_add_name_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string selecting = combo_add_name.Text;

                dbconnection ac = new dbconnection();
                ac.openconnection();
                string query64 = "select * from useraccounts where userid='" + selecting + "';";
                ac.command(query64);

                string firstname = "";
                string lastname  = "";
                string surname   = "";

                while (ac.readdata().Read())
                {
                    firstname = ac.readdata().GetString("firstname");
                    lastname  = ac.readdata().GetString("lastname");
                    surname   = ac.readdata().GetString("surname");
                }
                ac.closeconnection();
                full_name_label.Text = surname + " " + firstname + " " + lastname;

                dbconnection ab = new dbconnection();

                string query48 = "select billno as 'Transaction No',type as 'Type', amount as 'Paid Amount',rebillno as 'Recorrected Bill No',paiduserid as 'Paid User ID',paidusername as 'Paid User Name',date as 'Date',time as 'Time' from pharmacy.salarybills where userid='" + selecting + "' ;";

                ab.openconnection();
                ab.command(query48);

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = ab.command(query48);
                DataTable abc = new DataTable();
                sda.Fill(abc);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = abc;
                dataGridView1.DataSource = bsourse;
                sda.Update(abc);

                ab.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #8
0
        public void combo_choose_supplier_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string selecting = combo_choose_supplier.Text;

                dbconnection ab = new dbconnection();

                string query48 = "select billno as 'Transaction No',type as 'Type',paymenttype as 'Payment Type', paidamount as 'Paid Amount',rebillno as 'Recorrected Bill No',userid as 'User ID',username as 'User Name',date as 'Date',time as 'Time' from pharmacy.supplierbills where suppliername='" + selecting + "' ;";

                ab.openconnection();
                ab.command(query48);

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = ab.command(query48);
                DataTable abc = new DataTable();
                sda.Fill(abc);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = abc;
                dataGridView1.DataSource = bsourse;
                sda.Update(abc);

                ab.closeconnection();

                ab.openconnection();
                string query49   = "select * from suppliers where suppliername='" + selecting + "';";
                double oldamount = 0;
                int    supid     = 0;

                ab.command(query49);

                while (ab.readdata().Read())
                {
                    oldamount = ab.readdata().GetDouble("creditbalance");
                    supid     = ab.readdata().GetInt32("supplierid");
                }

                text_supid.Text        = supid.ToString();
                text_cred_balance.Text = oldamount.ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #9
0
        private void customer_window_Load(object sender, EventArgs e)
        {
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dataGridView1.BackgroundColor = Color.WhiteSmoke;

            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView1.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
            dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
            dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;

            try
            {
                dbconnection db = new dbconnection();
                db.openconnection();
                string query75 = "select * from lastthings;";
                db.command(query75);
                int cusid = 0;
                while (db.readdata().Read())
                {
                    cusid = db.readdata().GetInt32("cusid");
                }
                db.closeconnection();
                text_uid.Text = (cusid + 1).ToString();

                string query77 = "select customerid as 'Customer ID',firstname as 'First Name',lastname as 'Last Name',surname as 'Sure Name',dob as 'Date of Birth',nic as 'NIC No',mobile as 'Mobile',address1 as 'Address line1',address2 as 'Address line2',address3 as 'Address line3' from customer;";


                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = db.command(query77);
                DataTable abc = new DataTable();
                sda.Fill(abc);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = abc;
                dataGridView1.DataSource = bsourse;
                sda.Update(abc);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #10
0
        private void combo_detail_item_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                string       chooseitem = combo_detail_item.Text;
                string       query15    = "select * from stock where productname='" + chooseitem + "';";
                dbconnection hh         = new dbconnection();

                hh.openconnection();
                hh.command(query15);

                while (hh.readdata().Read())
                {
                    text_productid.Text = hh.readdata().GetInt32("productid").ToString();
                    text_pname.Text     = hh.readdata().GetString("productname");
                    text_buyprice.Text  = hh.readdata().GetDouble("buyprice").ToString();
                    text_sellprice.Text = hh.readdata().GetDouble("sellprice").ToString();
                    combo_ptype.Text    = hh.readdata().GetString("type");
                    combo_supplier.Text = hh.readdata().GetString("suppliers");
                }
                hh.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        void fillcombo()
        {
            string       query48 = "select * from useraccounts;";
            dbconnection ab      = new dbconnection();

            ab.openconnection();
            ab.command(query48);

            int word = 0;


            while (ab.readdata().Read())
            {
                word = ab.readdata().GetInt32("userid");

                combo_add_name.Items.Add(word);
            }
        }
Example #12
0
        private void bunifuThinButton26_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            dbconnection aa      = new dbconnection();
            string       query23 = "select * from lastthings;";

            aa.openconnection();
            aa.command(query23);

            int pid = 0;

            while (aa.readdata().Read())
            {
                pid = aa.readdata().GetInt32("productid");
            }

            productid_label.Text = (pid + 1).ToString();
            text_newproductname.Focus();
        }
Example #13
0
        private void combo_choose_item_SelectedIndexChanged(object sender, EventArgs e)
        {
            dbconnection gh = new dbconnection();

            string selecting = combo_choose_item.Text;

            try
            {
                string query41 = "select * from stock where productname='" + selecting + "';";
                gh.openconnection();
                gh.command(query41);

                while (gh.readdata().Read())
                {
                    availble_qty.Text = gh.readdata().GetInt32("quantity").ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        public void recorrectz()
        {
            try
            {
                dbconnection ab = new dbconnection();
                ab.openconnection();
                string query70   = "select * from lastthings ;";
                int    oldbillno = 0;
                ab.command(query70);
                while (ab.readdata().Read())
                {
                    oldbillno = ab.readdata().GetInt32("salaryinvoice");
                }
                ab.closeconnection();


                string firstname = "";
                string lastname  = "";
                string username  = "";


                ab.openconnection();
                string query71 = "select * from useraccounts where userid='" + combo_add_name.Text + "';";
                ab.command(query71);
                while (ab.readdata().Read())
                {
                    firstname = ab.readdata().GetString("firstname");
                    lastname  = ab.readdata().GetString("lastname");
                    username  = ab.readdata().GetString("usernames");
                }

                string   fname     = firstname;
                string   lname     = lastname;
                string   uname     = username;
                string   uid       = combo_add_name.Text;
                int      newbillno = oldbillno + 1;
                string   type      = "Re-Correction";
                string   renum     = text_rebillnum.Text;
                string   puid      = uidlabal.Text;
                string   puname    = unamezzz.Text;
                DateTime dt        = DateTime.Now;
                string   datenow   = dt.ToString("yyyy-MM-dd");
                string   timenow   = dt.ToString("HH:mm:ss");

                string query72 = "insert into salarybills (firstname,lastname,username,userid,billno,type,rebillno,paiduserid,paidusername,date,time)values('" + fname + "','" + lname + "','" + uname + "','" + uid + "','" + newbillno + "','" + type + "','" + renum + "','" + puid + "','" + puname + "','" + datenow + "','" + timenow + "');";
                ab.openconnection();
                ab.command(query72).ExecuteNonQuery();
                ab.closeconnection();

                ab.openconnection();
                string query68 = "update lastthings set salaryinvoice='" + newbillno + "' where salaryinvoice='" + oldbillno + "';";
                ab.command(query68).ExecuteNonQuery();
                ab.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #15
0
        private void cashier_window_Load(object sender, EventArgs e)
        {
            dataGridView1.BorderStyle = BorderStyle.None;
            dataGridView1.AlternatingRowsDefaultCellStyle.BackColor = Color.FromArgb(238, 239, 249);
            dataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.SingleHorizontal;
            dataGridView1.DefaultCellStyle.SelectionBackColor = Color.DarkTurquoise;
            dataGridView1.DefaultCellStyle.SelectionForeColor = Color.WhiteSmoke;
            dataGridView1.BackgroundColor = Color.WhiteSmoke;

            dataGridView1.EnableHeadersVisualStyles = false;
            dataGridView1.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
            dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
            dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;


            dbconnection ac = new dbconnection();

            try
            {
                string query40 = "select * from stock;";

                ac.openconnection();
                ac.command(query40);

                string word = "";

                while (ac.readdata().Read())
                {
                    word = ac.readdata().GetString("productname");
                    combo_choose_item.Items.Add(word);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #16
0
        void Fillcombo()
        {
            try
            {
                dbconnection ds = new dbconnection();

                string query9  = "select * from stock;";
                string query14 = "select * from suppliers;";
                ds.openconnection();
                ds.command(query9);

                while (ds.readdata().Read())
                {
                    string word = ds.readdata().GetString("productname");
                    combo_add_item.Items.Add(word);
                    combo_reduce_item.Items.Add(word);
                    combo_detail_item.Items.Add(word);
                }
                ds.closeconnection();

                ds.openconnection();
                ds.command(query14);

                while (ds.readdata().Read())
                {
                    string keys = ds.readdata().GetString("suppliername");
                    combo_supplier.Items.Add(keys);
                }

                ds.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #17
0
        public void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection ac        = new dbconnection();
                double       oldamount = 0;
                string       selecting = combo_choose_supplier.Text;
                string       query49   = "select * from  suppliers where suppliername='" + selecting + "'; ";
                ac.openconnection();
                ac.command(query49);

                while (ac.readdata().Read())
                {
                    oldamount = ac.readdata().GetDouble("creditbalance");
                }
                ac.closeconnection();

                double payment = double.Parse(text_payment.Text);

                double newcreditbalance = oldamount - payment;
                text_cred_balance.Text = newcreditbalance.ToString();

                ac.openconnection();
                string query50 = "update suppliers set creditbalance='" + newcreditbalance + "' where suppliername='" + selecting + "';";
                ac.command(query50).ExecuteNonQuery();
                ac.closeconnection();

                int oldbillnumber = 0;
                ac.openconnection();
                string query51 = "select * from lastthings;";
                ac.command(query51);
                while (ac.readdata().Read())
                {
                    oldbillnumber = ac.readdata().GetInt32("supplierinvoice");
                }
                ac.closeconnection();


                string   supname       = combo_choose_supplier.Text;
                int      newbillnumber = oldbillnumber + 1;
                string   typez         = "Payment";
                string   paymenttype   = paytype;
                double   paidamount    = double.Parse(text_payment.Text);
                string   userid        = uidlabal.Text;
                string   username      = unamezzz.Text;
                DateTime dt            = DateTime.Now;
                string   datenow       = dt.ToString("yyyy-MM-dd");
                string   timenow       = dt.ToString("HH:mm:ss");

                ac.openconnection();
                string query52 = "insert into supplierbills(suppliername,billno,type,paymenttype,paidamount,userid,username,date,time)values('" + supname + "','" + newbillnumber + "','" + typez + "','" + paymenttype + "','" + paidamount + "','" + userid + "','" + username + "','" + datenow + "','" + timenow + "');";
                ac.command(query52).ExecuteNonQuery();


                string query53 = "update lastthings set supplierinvoice='" + newbillnumber + "' where supplierinvoice='" + oldbillnumber + "';";
                ac.command(query53).ExecuteNonQuery();
                ac.closeconnection();


                combo_choose_supplier_SelectedIndexChanged(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #18
0
        private void bunifuThinButton22_Click(object sender, EventArgs e)
        {
            try
            {
                if (combo_reduce_item.Text == "" || text_qty_reduse.Text == "" || reosonbox.Text == "")
                {
                    MessageBox.Show("You Cannot Keep Blank Field");
                    combo_reduce_item.Focus();
                }
                else
                {
                    dbconnection cs = new dbconnection();

                    string product  = combo_reduce_item.Text;
                    int    newqty   = Int32.Parse(text_qty_reduse.Text);
                    int    existqty = 0;
                    bool   correct  = false;

                    string query13 = "select * from stock where productname='" + product + "';";

                    cs.openconnection();
                    cs.command(query13);

                    while (cs.readdata().Read())
                    {
                        existqty = cs.readdata().GetInt32("quantity");
                        correct  = true;
                    }


                    if (correct == true)
                    {
                        if (newqty > existqty)
                        {
                            MessageBox.Show("There are not enough items to reduce");
                            text_qty_reduse.Focus();
                        }
                        else
                        {
                            int qqty = existqty - newqty;


                            string query11 = "update stock set quantity='" + qqty + "' where productname='" + product + "';";
                            cs.openconnection();
                            cs.command(query11).ExecuteNonQuery();
                            cs.closeconnection();

                            reduse_available.Text = qqty.ToString();
                            text_qty_reduse.Text  = "";
                            reosonbox.Text        = "";
                            combo_reduce_item.Focus();


                            string query63 = "select * from stock  where productname='" + product + "';"; cs.openconnection();
                            cs.command(query63);
                            double buyprice = 0;
                            string supname  = "";
                            while (cs.readdata().Read())
                            {
                                buyprice = cs.readdata().GetDouble("buyprice");
                                supname  = cs.readdata().GetString("suppliers");
                            }
                            cs.closeconnection();


                            double crebalance = 0;
                            cs.openconnection();
                            string query64 = "select * from suppliers where suppliername='" + supname + "';";
                            cs.command(query64);
                            while (cs.readdata().Read())
                            {
                                crebalance = cs.readdata().GetDouble("creditbalance");
                            }
                            cs.closeconnection();


                            double total         = newqty * buyprice;
                            double newcrebalance = crebalance - total;
                            cs.openconnection();
                            string query65 = "update suppliers set creditbalance='" + newcrebalance + "' where suppliername='" + supname + "';";
                            cs.command(query65).ExecuteNonQuery();
                            cs.closeconnection();



                            MessageBox.Show("Redusing Item Is Successfull");
                        }
                    }
                    else
                    {
                        MessageBox.Show("This product is not exist in the stock");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #19
0
        private void bunifuThinButton23_Click(object sender, EventArgs e)
        {
            try
            {
                string ppid         = text_productid.Text;
                string newpname     = text_pname.Text;
                double newbuyprice  = double.Parse(text_buyprice.Text);
                double newsellprice = double.Parse(text_sellprice.Text);
                string newtype      = combo_ptype.Text;
                string newsupplier  = combo_supplier.Text;

                dbconnection gh = new dbconnection();
                gh.openconnection();
                string query17  = "select * from stock where productid='" + ppid + "';";
                string oldpname = "";
                gh.command(query17);

                while (gh.readdata().Read())
                {
                    oldpname = gh.readdata().GetString("productname");
                }
                gh.closeconnection();

                bool bosupplier = false;


                if (combo_supplier.SelectedIndex > -1)
                {
                    bosupplier = true;
                }



                bool botype = false;

                if (combo_ptype.SelectedIndex > -1)
                {
                    botype = true;
                }

                if (ppid == "")
                {
                    MessageBox.Show("You do not have selected a item");
                }
                else
                {
                    double x = Double.Parse(text_buyprice.Text);
                    double y = Double.Parse(text_sellprice.Text);
                    if (text_pname.Text == "" || x == 0 || y == 0 || combo_ptype.Text == "" || combo_supplier.Text == "")
                    {
                        MessageBox.Show("You can not keep blank fields");
                    }
                    else
                    {
                        if ((botype == false || bosupplier == false) || (botype == false && bosupplier == false))
                        {
                            MessageBox.Show("The Supplier name or Type is not exist in the system");
                        }
                        else
                        {
                            if (newpname == oldpname)
                            {
                                string query18 = "update stock set productname='" + newpname + "',buyprice='" + newbuyprice + "',sellprice='" + newsellprice + "',type='" + newtype + "',suppliers='" + newsupplier + "' where productid='" + ppid + "';";

                                gh.openconnection();
                                gh.command(query18).ExecuteNonQuery();
                                gh.closeconnection();
                                combo_detail_item.Items.Clear();
                                combo_reduce_item.Items.Clear();
                                combo_add_item.Items.Clear();

                                Fillcombo();
                                MessageBox.Show("updating is sucessfull");
                            }
                            else
                            {
                                string query19 = "select * from stock where productname='" + newpname + "';";
                                gh.openconnection();
                                gh.command(query19);
                                bool correct = false;

                                while (gh.readdata().Read())
                                {
                                    correct = true;
                                }

                                if (correct == true)
                                {
                                    MessageBox.Show("the product name that you enterd is available in the system.try another product name");
                                }
                                else
                                {
                                    string query18 = "update stock set productname='" + newpname + "',buyprice='" + newbuyprice + "',sellprice='" + newsellprice + "',type='" + newtype + "',suppliers='" + newsupplier + "' where productid='" + ppid + "';";

                                    gh.openconnection();
                                    gh.command(query18).ExecuteNonQuery();
                                    gh.closeconnection();
                                    combo_detail_item.Items.Clear();
                                    combo_reduce_item.Items.Clear();
                                    combo_add_item.Items.Clear();

                                    Fillcombo();
                                    MessageBox.Show("updating is sucessfull");
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("You cannot keep blank fields");
            }
        }
Example #20
0
        private void minusqty_Click(object sender, EventArgs e)
        {
            try
            {
                int selecitem = dataGridView1.SelectedRows.Count;
                if (selecitem == 1)
                {
                    string pnamez  = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                    string query43 = "select * from stock where productname='" + pnamez + "';";

                    dbconnection ac = new dbconnection();
                    ac.openconnection();
                    ac.command(query43);
                    int sysqty = 0;

                    while (ac.readdata().Read())
                    {
                        sysqty = ac.readdata().GetInt32("quantity");
                    }

                    int oldqty = Int32.Parse(dataGridView1.CurrentRow.Cells[2].Value.ToString());
                    if (oldqty == 1)
                    {
                        MessageBox.Show("You can not increas quantity");
                    }
                    else
                    {
                        int newold = oldqty - 1;

                        dataGridView1.CurrentRow.Cells[2].Value = newold.ToString();

                        double oldsubtotal = double.Parse(dataGridView1.CurrentRow.Cells[5].Value.ToString());

                        double discount  = double.Parse(dataGridView1.CurrentRow.Cells[4].Value.ToString());
                        double sellprice = double.Parse(dataGridView1.CurrentRow.Cells[3].Value.ToString());

                        double newsubtotal = (sellprice * newold) - (sellprice * newold * discount) / 100;

                        dataGridView1.CurrentRow.Cells[5].Value = newsubtotal.ToString();

                        total_Amount_label.Text = (double.Parse(total_Amount_label.Text) - oldsubtotal + newsubtotal).ToString();

                        if (text_cash.Text == "")
                        {
                            balance_text.Text = "0.00";
                        }
                        else
                        {
                            double total       = double.Parse(total_Amount_label.Text);
                            double cash        = double.Parse(text_cash.Text);
                            double returntotal = double.Parse(return_amount.Text);

                            balance_text.Text = (cash - total - returntotal).ToString();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("One row should be selected to change quantity");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #21
0
        private void button_cash_Click(object sender, EventArgs e)
        {
            if (dataGridView1.Rows.Count < 1)
            {
                MessageBox.Show("Invoice is empty");
                text_cash.Text = ctext;
            }


            else if (text_cash.Text == "" || double.Parse(balance_text.Text) <= 0)
            {
                MessageBox.Show("Not enough money to pay the bill");
                text_cash.Text = ctext;
            }
            else
            {
                try
                {
                    dbconnection aa = new dbconnection();

                    aa.openconnection();
                    string query44 = "select * from lastthings;";
                    aa.command(query44);
                    int lastbillnumber = 0;

                    while (aa.readdata().Read())
                    {
                        lastbillnumber = aa.readdata().GetInt32("billnumber");
                    }
                    aa.closeconnection();
                    int newbillnumber = lastbillnumber + 1;


                    DateTime dt           = DateTime.Now;
                    string   datenow      = dt.ToString("yyyy-MM-dd");
                    string   timenow      = dt.ToString("hh:mm:ss");
                    string   uid          = uidlabal.Text;
                    string   uname        = unamezzz.Text;
                    double   totalamount  = double.Parse(total_Amount_label.Text);
                    double   returnamount = double.Parse(return_amount.Text);
                    double   cashamount   = double.Parse(text_cash.Text);
                    double   balance      = double.Parse(balance_text.Text);
                    string   selltype     = "Cash";



                    aa.openconnection();
                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        string query45 = "insert into cashier(billnumber,itemname,quantity,sellprice,discount,subtotal,total,balance,cash,returnamount,date,time,userid,username,selltype) values('" + newbillnumber + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + Int32.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString()) + "','" + double.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString()) + "','" + double.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString()) + "','" + double.Parse(dataGridView1.Rows[i].Cells[5].Value.ToString()) + "','" + totalamount + "','" + balance + "','" + cashamount + "','" + returnamount + "','" + datenow + "','" + timenow + "','" + uid + "','" + uname + "','" + selltype + "');";

                        aa.command(query45).ExecuteNonQuery();
                    }
                    aa.closeconnection();

                    aa.openconnection();
                    string query46 = "update lastthings set billnumber='" + newbillnumber + "' where billnumber='" + lastbillnumber + "';";
                    aa.command(query46).ExecuteNonQuery();
                    aa.closeconnection();

                    for (int i = 0; i < dataGridView1.Rows.Count; i++)
                    {
                        aa.openconnection();
                        string query47 = "select * from stock where productname='" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "';";
                        aa.command(query47);

                        int oldquantity = 0;
                        while (aa.readdata().Read())
                        {
                            oldquantity = aa.readdata().GetInt32("quantity");
                        }

                        int cashquantity = Int32.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString());

                        int newquantity = oldquantity - cashquantity;

                        aa.closeconnection();

                        aa.openconnection();
                        string query48 = "update stock set quantity='" + newquantity + "' where productname='" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "';";
                        aa.command(query48).ExecuteNonQuery();
                        aa.closeconnection();
                    }


                    MessageBox.Show("Sold");
                    cashier_window_Load(sender, e);
                    button4_Click(sender, e);
                    combo_choose_item.Focus();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Example #22
0
        private void button_add_item_Click(object sender, EventArgs e)
        {
            try
            {
                bool correctpname = false;
                bool correctqty   = false;
                bool correctdis   = false;

                string       pname = combo_choose_item.Text;
                dbconnection gg    = new dbconnection();

                string query42 = "select * from stock where productname='" + pname + "';";
                gg.openconnection();
                gg.command(query42);

                while (gg.readdata().Read())
                {
                    correctpname = true;
                }

                gg.closeconnection();

                /////////////////////////////////////

                int avqty  = Int32.Parse(availble_qty.Text);
                int newqty = Int32.Parse(text_qty_add.Text);

                if (newqty <= avqty && newqty > 0)
                {
                    correctqty = true;
                }

                /////////////////////////////////

                double dis = double.Parse(discount_text.Text);

                if (dis <= 100)
                {
                    correctdis = true;
                }

                if (correctpname == true && correctdis == true && correctqty == true)
                {
                    string query43 = "select * from stock where productname='" + pname + "';";
                    gg.openconnection();
                    gg.command(query43);

                    int    pid       = 0;
                    double sellprice = 0;

                    while (gg.readdata().Read())
                    {
                        pid       = gg.readdata().GetInt32("productid");
                        sellprice = gg.readdata().GetDouble("sellprice");
                    }

                    int rownum = dataGridView1.Rows.Add();

                    dataGridView1.Rows[rownum].Cells[0].Value = pid.ToString();
                    dataGridView1.Rows[rownum].Cells[1].Value = pname;
                    dataGridView1.Rows[rownum].Cells[2].Value = newqty.ToString();
                    dataGridView1.Rows[rownum].Cells[3].Value = sellprice.ToString();
                    dataGridView1.Rows[rownum].Cells[4].Value = dis.ToString();

                    double subtotal = (newqty * sellprice) - (newqty * sellprice * dis) / 100;

                    double newsub = Math.Round(subtotal, 2);

                    dataGridView1.Rows[rownum].Cells[5].Value = newsub.ToString();

                    if (text_cash.Text == "")
                    {
                        double totalvalue = double.Parse(total_Amount_label.Text);

                        double newtotal = totalvalue + newsub;

                        total_Amount_label.Text = Math.Round(newtotal, 2).ToString();
                    }
                    else
                    {
                        double totalvalue = double.Parse(total_Amount_label.Text);

                        double newtotal = totalvalue + newsub;

                        total_Amount_label.Text = Math.Round(newtotal, 2).ToString();

                        double newcash     = double.Parse(text_cash.Text);
                        double returnvalue = double.Parse(return_amount.Text);
                        double balance     = newcash - newtotal - returnvalue;

                        balance_text.Text = Math.Round(balance, 2).ToString();
                    }

                    int told = Int32.Parse(Total_item_text.Text);

                    Total_item_text.Text = (told + 1).ToString();

                    combo_choose_item.Text = "";
                    availble_qty.Text      = "0";
                    text_qty_add.Text      = "0";
                    discount_text.Text     = "0";
                }

                else
                {
                    MessageBox.Show("invalied details");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("check fields");
            }
        }
        private void button_recorrect_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection ab = new dbconnection();

                bool sname = false;

                if (combo_add_name.SelectedIndex > -1)
                {
                    sname = true;
                }

                bool   correct   = false;
                double oldsalary = 0;
                int    renum     = Int32.Parse(text_rebillnum.Text);
                ab.openconnection();
                string query68 = "select * from salarybills where billno='" + renum + "' and userid='" + combo_add_name.Text + "';";
                ab.command(query68);
                while (ab.readdata().Read())
                {
                    correct = true;
                }
                ab.closeconnection();

                if (text_rebillnum.Text == "")
                {
                    MessageBox.Show("Enter Transaction No");
                }
                else
                {
                    if (sname == true && correct == true)
                    {
                        ab.openconnection();
                        string query69 = "select * from salarybills where billno='" + text_rebillnum.Text + "';";
                        string btype   = "";
                        ab.command(query69);
                        while (ab.readdata().Read())
                        {
                            btype = ab.readdata().GetString("type");
                        }
                        ab.closeconnection();


                        dbconnection ac      = new dbconnection();
                        bool         re      = false;
                        string       query70 = "select * from salarybills where rebillno='" + text_rebillnum.Text + "';";
                        ac.openconnection();
                        ac.command(query70);

                        while (ac.readdata().Read())
                        {
                            re = true;
                        }
                        ac.closeconnection();



                        if (btype == "Re-Correction")
                        {
                            MessageBox.Show("You can't Re-Correction this Transaction");
                        }
                        else if (re == true)
                        {
                            MessageBox.Show("this transaction already has been Re - corrected");
                        }
                        else
                        {
                            yesnofrm cc = new yesnofrm(10);
                            cc.Owner       = this;
                            cc.warningtext = "Are You Sure To Re-Correct ?";
                            cc.Show();
                            this.Enabled = false;
                        }
                    }
                    else
                    {
                        MessageBox.Show("Bill no is not existing with this user or invalied bill number");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #24
0
        public void savedetails()
        {
            int allrow = dataGridView1.Rows.Count;

            dbconnection ac = new dbconnection();

            ac.openconnection();
            string query25 = "select * from lastthings;";

            ac.command(query25);
            int oldpid = 0;

            while (ac.readdata().Read())
            {
                oldpid = ac.readdata().GetInt32("productid");
            }
            ac.closeconnection();

            for (int i = 0; i < allrow; i++)
            {
                int pid = Int32.Parse(dataGridView1.Rows[i].Cells[0].Value
                                      .ToString());
                string pname     = dataGridView1.Rows[i].Cells[1].Value.ToString();
                int    pquantity = Int32.Parse(dataGridView1.Rows[i].Cells[2].Value.ToString());
                double pbprice   = double.Parse(dataGridView1.Rows[i].Cells[3].Value.ToString());
                double psprice   = double.Parse(dataGridView1.Rows[i].Cells[4].Value.ToString());
                string ptype     = dataGridView1.Rows[i].Cells[5].Value.ToString();
                string psupplier = dataGridView1.Rows[i].Cells[6].Value.ToString();



                ac.openconnection();
                string query22 = "insert into stock values('" + pid + "','" + pname + "','" + pquantity + "','" + pbprice + "','" + psprice + "','" + ptype + "','" + psupplier + "');";
                ac.command(query22).ExecuteNonQuery();
                ac.closeconnection();

                double oldcrebalance = 0;
                ac.openconnection();
                string query66 = "select * from suppliers where suppliername='" + psupplier + "';";
                ac.command(query66);
                while (ac.readdata().Read())
                {
                    oldcrebalance = ac.readdata().GetDouble("creditbalance");
                }
                ac.closeconnection();

                double total         = pquantity * pbprice;
                double newcrebalance = total + oldcrebalance;
                ac.openconnection();
                string query67 = "update suppliers set creditbalance='" + newcrebalance + "' where suppliername='" + psupplier + "';";
                ac.command(query67).ExecuteNonQuery();
                ac.closeconnection();
            }
            MessageBox.Show("Saving successfull");

            int    lastpid = Int32.Parse(dataGridView1.Rows[allrow - 1].Cells[0].Value.ToString());
            string query24 = "update lastthings set productid='" + lastpid + "' where productid='" + oldpid + "';";

            ac.openconnection();
            ac.command(query24).ExecuteNonQuery();
            ac.closeconnection();
        }
        private void button_recorrect_Click(object sender, EventArgs e)
        {
            bool sname = false;

            if (combo_add_name.SelectedIndex > -1)
            {
                sname = true;
            }

            bool reportexist = false;

            try
            {
                if (sname == true)
                {
                    dbconnection ac = new dbconnection();
                    ac.openconnection();
                    string query73 = "select * from cashier where userid='" + combo_add_name.Text + "' and date='" + UA_date.Text + "';";
                    ac.command(query73);
                    while (ac.readdata().Read())
                    {
                        reportexist = true;
                    }
                    ac.closeconnection();

                    if (reportexist == true)
                    {
                        ac.openconnection();
                        string query74 = "select billnumber as 'Transaction No',itemname as 'Item',quantity as 'Quantity',sellprice as 'Sells Price',discount as 'Discount',subtotal as 'Sub Total',total as 'Total',cash as 'Cash',visa as 'Visa',balance as 'Balance',returnamount as 'Return Amount',time as 'Time',username as 'User Name', selltype as 'Sells Type' from cashier where userid='" + combo_add_name.Text + "' and date='" + UA_date.Text + "';";

                        MySqlDataAdapter sda = new MySqlDataAdapter();
                        sda.SelectCommand = ac.command(query74);
                        DataTable abc = new DataTable();
                        sda.Fill(abc);
                        BindingSource bsourse = new BindingSource();

                        bsourse.DataSource       = abc;
                        dataGridView1.DataSource = bsourse;
                        sda.Update(abc);

                        ac.closeconnection();

                        ac.openconnection();
                        string type    = "cash";
                        string query75 = "select sum(subtotal) from cashier where userid='" + combo_add_name.Text + "' and date='" + UA_date.Text + "' and selltype='" + type + "' ;";

                        double mySum = Convert.ToDouble(ac.command(query75).ExecuteScalar());
                        text_cash_balance.Text  = mySum.ToString();
                        text_total_balance.Text = text_cash_balance.Text;
                        ac.closeconnection();


                        dbconnection db   = new dbconnection();
                        bool         visa = false;
                        db.openconnection();
                        string tp      = "visa";
                        string query77 = "select * from cashier where userid='" + combo_add_name.Text + "' and date='" + UA_date.Text + "' and selltype='" + tp + "';";
                        db.command(query77);
                        while (db.readdata().Read())
                        {
                            visa = true;
                        }
                        db.closeconnection();



                        if (visa == true)
                        {
                            ac.openconnection();
                            string type1   = "visa";
                            string query76 = "select sum(subtotal) from cashier where userid='" + combo_add_name.Text + "' and date='" + UA_date.Text + "' and selltype='" + type1 + "' ;";

                            double mySum1 = Convert.ToDouble(ac.command(query76).ExecuteScalar());
                            text_visa_balance.Text = mySum1.ToString();
                            ac.closeconnection();

                            text_total_balance.Text = (mySum + mySum1).ToString();
                        }
                    }
                    else
                    {
                        MessageBox.Show("there are no records of this user for this date");
                        dataGridView1.Rows.Clear();
                    }
                }
                else
                {
                    MessageBox.Show("select user to open report");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #26
0
        public void recorrectionz()
        {
            try
            {
                dbconnection db = new dbconnection();

                int rebilno = Int32.Parse(text_rebillnum.Text);

                string query55 = "select * from supplierbills where billno='" + rebilno + "';";
                db.openconnection();
                db.command(query55);

                double oldamount = 0;
                while (db.readdata().Read())
                {
                    oldamount = db.readdata().GetDouble("paidamount");
                }
                db.closeconnection();



                db.openconnection();
                string query56 = "select * from suppliers where suppliername='" + combo_choose_supplier.Text + "';";
                db.command(query56);

                double supplieramount = 0;
                while (db.readdata().Read())
                {
                    supplieramount = db.readdata().GetDouble("creditbalance");
                }
                db.closeconnection();

                db.openconnection();

                double newamount = supplieramount + oldamount;
                string query57   = "update suppliers set creditbalance='" + newamount + "' where suppliername='" + combo_choose_supplier.Text + "';";
                db.command(query57).ExecuteNonQuery();
                db.closeconnection();

                int oldbillnum = 0;
                db.openconnection();
                string query58 = "select * from lastthings ;";
                db.command(query58);
                while (db.readdata().Read())
                {
                    oldbillnum = db.readdata().GetInt32("supplierinvoice");
                }
                db.closeconnection();


                string   supname    = combo_choose_supplier.Text;
                int      newbillnum = oldbillnum + 1;
                string   typezz     = "Re-Correction";
                int      rebilnoz   = Int32.Parse(text_rebillnum.Text);
                string   userid     = uidlabal.Text;
                string   uname      = unamezzz.Text;
                DateTime dt         = DateTime.Now;
                string   datenow    = dt.ToString("yyyy-MM-dd");
                string   timenow    = dt.ToString("HH:mm:ss");


                db.openconnection();
                string query59 = "insert into supplierbills(suppliername,billno,type,rebillno,userid,username,date,time)values('" + supname + "','" + newbillnum + "','" + typezz + "','" + rebilnoz + "','" + userid + "','" + uname + "','" + datenow + "','" + timenow + "') ;";
                db.command(query59).ExecuteNonQuery();
                db.closeconnection();

                db.openconnection();
                string query60 = "update lastthings set supplierinvoice='" + newbillnum + "' where supplierinvoice='" + oldbillnum + "';";
                db.command(query60).ExecuteNonQuery();
                db.closeconnection();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        private void butto_pay_Click(object sender, EventArgs e)
        {
            string selecting = combo_add_name.Text;

            string firstname = "";
            string lastname  = "";
            string surname   = "";
            string username  = "";

            dbconnection ac = new dbconnection();

            try
            {
                ac.openconnection();
                string query64 = "select * from useraccounts where userid='" + selecting + "';";
                ac.command(query64);



                while (ac.readdata().Read())
                {
                    firstname = ac.readdata().GetString("firstname");
                    lastname  = ac.readdata().GetString("lastname");
                    surname   = ac.readdata().GetString("surname");
                    username  = ac.readdata().GetString("usernames");
                }
                ac.closeconnection();


                string fullname = surname + " " + firstname + " " + lastname;
                ac.openconnection();
                int    oldbilno = 0;
                string query66  = "select * from lastthings;";
                ac.command(query66);
                while (ac.readdata().Read())
                {
                    oldbilno = ac.readdata().GetInt32("salaryinvoice");
                }
                ac.closeconnection();
                int newbilno = oldbilno + 1;

                if (fullname == full_name_label.Text)
                {
                    if (text_amount.Text == "")
                    {
                        MessageBox.Show("Enter the amount");
                    }
                    else
                    {
                        string   fname     = firstname;
                        string   lname     = lastname;
                        string   uname     = username;
                        string   uid       = selecting;
                        int      newbilnoz = newbilno;
                        string   type      = "Payment";
                        double   amount    = double.Parse(text_amount.Text);
                        string   paiduid   = uidlabal.Text;
                        string   paiduname = unamezzz.Text;
                        DateTime dt        = DateTime.Now;
                        string   datenow   = dt.ToString("yyyy-MM-dd");
                        string   timenow   = dt.ToString("HH:mm:ss");

                        ac.openconnection();
                        string query67 = "insert into salarybills(firstname,lastname,username,userid,billno,type,amount,paiduserid,paidusername,date,time)values('" + fname + "','" + lname + "','" + uname + "','" + uid + "','" + newbilnoz + "','" + type + "','" + amount + "','" + paiduid + "','" + paiduname + "','" + datenow + "','" + timenow + "')";
                        ac.command(query67).ExecuteNonQuery();
                        ac.closeconnection();

                        ac.openconnection();
                        string query68 = "update lastthings set salaryinvoice='" + newbilno + "' where salaryinvoice='" + oldbilno + "';";
                        ac.command(query68).ExecuteNonQuery();
                        ac.closeconnection();


                        combo_add_name_SelectedIndexChanged(sender, e);
                    }
                }

                else
                {
                    MessageBox.Show("Choose empolyee again");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #28
0
        private void UA_editbutton_Click(object sender, EventArgs e)
        {
            try
            {
                int selecrow = dataGridView2.SelectedRows.Count;

                if (selecrow > 1 || selecrow < 1)
                {
                    MessageBox.Show("You should select one row to edit");
                }
                else
                {
                    string uidz = dataGridView2.CurrentRow.Cells[0].Value.ToString();
                    dataGridView2.Enabled = false;

                    dbconnection db      = new dbconnection();
                    string       query31 = "select * from useraccounts where userid='" + uidz + "';";
                    db.openconnection();
                    db.command(query31);

                    int      uaid         = 0;
                    string   uaname       = "";
                    string   uatype       = "";
                    string   uafirstname  = "";
                    string   ualastname   = "";
                    string   uasurename   = "";
                    string   uanicnumber  = "";
                    DateTime uadob        = new DateTime();
                    string   uamnumber    = "";
                    string   uaaddrenum   = "";
                    string   uaaddrstreet = "";
                    string   uaaddretown  = "";

                    while (db.readdata().Read())
                    {
                        uaid         = db.readdata().GetInt32("userid");
                        uaname       = db.readdata().GetString("usernames");
                        uatype       = db.readdata().GetString("type");
                        uafirstname  = db.readdata().GetString("firstname");
                        ualastname   = db.readdata().GetString("lastname");
                        uasurename   = db.readdata().GetString("surname");
                        uanicnumber  = db.readdata().GetString("nationalid");
                        uadob        = db.readdata().GetDateTime("dob");
                        uamnumber    = db.readdata().GetString("mobile");
                        uaaddrenum   = db.readdata().GetString("addressnum");
                        uaaddrstreet = db.readdata().GetString("addressstreet");
                        uaaddretown  = db.readdata().GetString("addresstown");
                    }

                    UA_userid.Text        = uaid.ToString();
                    UA_username.Text      = uaname;
                    UA_type.Text          = uatype;
                    UA_firstname.Text     = uafirstname;
                    UA_lastname.Text      = ualastname;
                    UA_surname.Text       = uasurename;
                    UA_nic.Text           = uanicnumber;
                    UA_date.Text          = uadob.ToString("yyyy/MM/dd");
                    UA_mobnumber.Text     = uamnumber;
                    UA_addressnum.Text    = uaaddrenum;
                    UA_addressstreet.Text = uaaddrstreet;
                    UA_addresstown.Text   = uaaddretown;

                    db.closeconnection();


                    UA_type.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #29
0
        //yess butttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
        public void yesbutton_Click(object sender, EventArgs e)
        {
            if (y == 1)
            {
                //main frame close
                try
                {
                    main_window frm = (main_window)this.Owner;


                    yesbutton.Enabled = false;
                    frm.Close();

                    this.Close();
                    login_window abc = new login_window();


                    abc.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            else if (n == 2)
            {
                //setting page save
                try
                {
                    dbconnection xy = new dbconnection();

                    main_window arm = (main_window)this.Owner;

                    string query3 = "select * from useraccounts where usernames='" + susername + "';";
                    string query4 = "select * from useraccounts where password='******' and userid='" + uid + "';";

                    //get old user namesis
                    xy.openconnection();
                    xy.command(query3);
                    bool olduseris = false;
                    while (xy.readdata().Read())
                    {
                        olduseris = true;
                    }
                    xy.closeconnection();


                    //get old password
                    xy.openconnection();
                    xy.command(query4);
                    bool oldpasis = false;
                    while (xy.readdata().Read())
                    {
                        oldpasis = true;
                    }
                    xy.closeconnection();



                    //use old user name......................................
                    if (susername == olduname)
                    {
                        if ((oldpasis == true) && (snewpas != soldpas) && (snewpas == srenewpad) && (snewpas != ""))
                        {
                            //write correct cod

                            string query5 = "update useraccounts set usernames='" + susername + "',password='******' where userid='" + uid + "';";

                            xy.openconnection();
                            xy.command(query5).ExecuteNonQuery();
                            xy.closeconnection();

                            MessageBox.Show("The Changing setting is succesfull");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                        else if ((oldpasis == true) && (snewpas != soldpas) && (snewpas != srenewpad))
                        {
                            MessageBox.Show("The new passwords are not matching!!! Type them correctly");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                        else if ((oldpasis == true) && (soldpas != snewpas) && ((snewpas == "") || (srenewpad) == ""))
                        {
                            MessageBox.Show("You cannot keep Blank password fields");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                        else if (oldpasis == false)
                        {
                            MessageBox.Show("The old Password is wrong!!!");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("Fill the Fields Correctly");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                    }

                    else if (susername != olduname)
                    {
                        if (olduseris == false)
                        {
                            if ((oldpasis == true) && (snewpas != soldpas) && (snewpas == srenewpad) && (snewpas != ""))
                            {
                                //write correct code
                                string query5 = "update useraccounts set usernames='" + susername + "',password='******' where userid='" + uid + "';";

                                xy.openconnection();
                                xy.command(query5).ExecuteNonQuery();
                                xy.closeconnection();

                                MessageBox.Show("The Changing setting is succesfull");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                            else if ((oldpasis == true) && (snewpas == "") && (srenewpad == ""))
                            {
                                string query7 = "update useraccounts set usernames='" + susername + "' where userid='" + uid + "';";
                                xy.openconnection();
                                xy.command(query7).ExecuteNonQuery();
                                xy.closeconnection();

                                MessageBox.Show("UserName Changing is successfull");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                            else if ((oldpasis == true) && (snewpas != soldpas) && (snewpas != srenewpad))
                            {
                                MessageBox.Show("The new passwords are not matching!!! Type them correctly");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                            else if ((oldpasis == true) && (soldpas != snewpas) && ((snewpas == "") || (srenewpad) == ""))
                            {
                                MessageBox.Show("You cannot keep Blank password fields");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                            else if (oldpasis == false)
                            {
                                MessageBox.Show("The old Password is wrong!!!");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                            else
                            {
                                MessageBox.Show("Fill the Fields Correctly");
                                arm.Enabled       = true;
                                yesbutton.Enabled = false;
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBox.Show("The UserName that  you enterd is available. Type another user name");
                            arm.Enabled       = true;
                            yesbutton.Enabled = false;
                            this.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else if (y == 3)
            {
                try
                {
                    newitem_window ab = (newitem_window)this.Owner;
                    ab.Enabled = true;
                    ab.savedetails();
                    yesbutton.Enabled = false;
                    ab.cleardata();
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            else if (y == 4)
            {
                try
                {
                    newitem_window frm = (newitem_window)this.Owner;
                    yesbutton.Enabled = false;
                    frm.savedetails();

                    frm.Enabled = true;
                    frm.closeform();
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else if (y == 5)
            {
                try
                {
                    main_window ff = (main_window)this.Owner;
                    yesbutton.Enabled = false;
                    ff.bunifuThinButton23_Click(sender, e);
                    ff.Enabled = true;
                    this.Close();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            else if (y == 6)
            {
                try
                {
                    main_window gg = (main_window)this.Owner;
                    yesbutton.Enabled = false;

                    gg.Enabled = true;
                    gg.useraccountsave();
                    this.Close();
                }
                catch (Exception)
                {
                    throw;
                }
            }

            else if (y == 7)
            {
                newuserform gb = (newuserform)this.Owner;
                yesbutton.Enabled = false;

                gb.Enabled = true;
                gb.savedata();
                this.Close();
            }

            else if (y == 8)
            {
                supplier_payment_form gb = (supplier_payment_form)this.Owner;
                yesbutton.Enabled = false;

                gb.Enabled = true;
                gb.bunifuThinButton21_Click(sender, e);
                gb.combo_choose_supplier_SelectedIndexChanged(sender, e);
                this.Close();
            }

            else if (y == 9)
            {
                supplier_payment_form gb = (supplier_payment_form)this.Owner;
                yesbutton.Enabled = false;

                gb.Enabled = true;
                gb.recorrectionz();
                gb.combo_choose_supplier_SelectedIndexChanged(sender, e);
                this.Close();
            }

            else if (y == 10)
            {
                salarypayment_window gb = (salarypayment_window)this.Owner;
                yesbutton.Enabled = false;

                gb.Enabled = true;
                gb.recorrectz();
                gb.combo_add_name_SelectedIndexChanged(sender, e);
                this.Close();
            }
        }
Example #30
0
        private void button_recorrect_Click(object sender, EventArgs e)
        {
            try
            {
                dbconnection db = new dbconnection();

                bool sname = false;

                if (combo_choose_supplier.SelectedIndex > -1)
                {
                    sname = true;
                }

                bool billnumber = false;
                int  billnums   = Int32.Parse(text_rebillnum.Text);
                db.openconnection();
                string query54 = "select * from supplierbills where suppliername='" + combo_choose_supplier.Text + "' and billno='" + billnums + "';";
                db.command(query54);
                while (db.readdata().Read())
                {
                    billnumber = true;
                }
                db.closeconnection();

                int    rebno = Int32.Parse(text_rebillnum.Text);
                string btype = "";
                db.openconnection();
                string query61 = "select * from supplierbills where billno='" + rebno + "';";
                db.command(query61);
                while (db.readdata().Read())
                {
                    btype = db.readdata().GetString("type");
                }
                db.closeconnection();

                bool re = false;
                db.openconnection();
                string query62 = "select * from supplierbills where rebillno='" + Int32.Parse(text_rebillnum.Text) + "';";
                db.command(query62);
                while (db.readdata().Read())
                {
                    re = true;
                }



                if (sname == true && billnumber == true)
                {
                    if (btype == "Re-Correction")
                    {
                        MessageBox.Show("You can't Re-Correction this Transaction");
                    }
                    else if (re == true)
                    {
                        MessageBox.Show("this transaction already has been Re-corrected");
                    }
                    else
                    {
                        yesnofrm cc = new yesnofrm(9);
                        cc.Owner       = this;
                        cc.warningtext = "Are You Sure To Re-Correct ?";
                        cc.Show();
                        this.Enabled = false;
                    }
                }


                else
                {
                    MessageBox.Show("Bill no is not existing with this supplier or invalied bill number");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }