コード例 #1
0
ファイル: newitem_window.cs プロジェクト: isuru21524/pharmacy
        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();
        }
コード例 #2
0
        private void text_stock_serchbox_TextChanged(object sender, EventArgs e)
        {
            string keyword = text_stock_serchbox.Text;

            if (keyword != null)
            {
                String query9 = "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 salarybills where userid='" + combo_add_name.Text + "' and (billno like '%" + keyword + "%' or type like '%" + keyword + "%' or date like '%" + keyword + "%' or rebillno like '%" + keyword + "%' );";

                dbconnection dbs = new dbconnection();
                dbs.openconnection();

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = dbs.command(query9);
                DataTable dbtab = new DataTable();
                sda.Fill(dbtab);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = dbtab;
                dataGridView1.DataSource = bsourse;
                sda.Update(dbtab);
            }
            else
            {
            }
        }
コード例 #3
0
        private void text_stock_serchbox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string keyword = text_stock_serchbox.Text;

                if (keyword != null)
                {
                    String query9 = "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',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 + "' and billnumber like '%" + keyword + "%' ;";

                    dbconnection dbs = new dbconnection();
                    dbs.openconnection();

                    MySqlDataAdapter sda = new MySqlDataAdapter();
                    sda.SelectCommand = dbs.command(query9);
                    DataTable dbtab = new DataTable();
                    sda.Fill(dbtab);
                    BindingSource bsourse = new BindingSource();

                    bsourse.DataSource       = dbtab;
                    dataGridView1.DataSource = bsourse;
                    sda.Update(dbtab);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #4
0
        private void text_stock_serchbox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string keyword = text_stock_serchbox.Text;

                if (keyword != null)
                {
                    String query9 = "select billno as 'Transaction No',type as 'Type',paymenttype as 'Payment Type',paidamount as 'Paid Amount',rebillno as 'Re-Corrected Bill No',userid as 'User ID',username as 'User Name',date as 'Date',time as 'Time' from supplierbills where suppliername='" + combo_choose_supplier.Text + "' and (billno  like '%" + keyword + "%' or rebillno like '%" + keyword + "%' or type like '%" + keyword + "%' or paymenttype like '%" + keyword + "%' or date like '%" + keyword + "%');";

                    dbconnection dbs = new dbconnection();
                    dbs.openconnection();

                    MySqlDataAdapter sda = new MySqlDataAdapter();
                    sda.SelectCommand = dbs.command(query9);
                    DataTable dbtab = new DataTable();
                    sda.Fill(dbtab);
                    BindingSource bsourse = new BindingSource();

                    bsourse.DataSource       = dbtab;
                    dataGridView1.DataSource = bsourse;
                    sda.Update(dbtab);
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #5
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());
            }
        }
コード例 #6
0
ファイル: stockform.cs プロジェクト: isuru21524/pharmacy
        private void text_stock_serchbox_TextChanged(object sender, EventArgs e)
        {
            try
            {
                string keyword = text_stock_serchbox.Text;

                if (keyword != null)
                {
                    String query9 = "select productid as 'Product_ID',productname as 'Product_Name',quantity as 'Quantity',buyprice as 'Buying_Price',sellprice as 'Selling_Price',suppliers as 'Supplier',type as 'Type' from stock where productid  like '%" + keyword + "%' or productname like '%" + keyword + "%' or suppliers like '%" + keyword + "%';";

                    dbconnection dbs = new dbconnection();
                    dbs.openconnection();

                    MySqlDataAdapter sda = new MySqlDataAdapter();
                    sda.SelectCommand = dbs.command(query9);
                    DataTable dbtab = new DataTable();
                    sda.Fill(dbtab);
                    BindingSource bsourse = new BindingSource();

                    bsourse.DataSource       = dbtab;
                    dataGridView1.DataSource = bsourse;
                    sda.Update(dbtab);
                }
                else
                {
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #7
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());
            }
        }
コード例 #8
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());
            }
        }
コード例 #9
0
        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());
            }
        }
コード例 #10
0
ファイル: main_window.cs プロジェクト: isuru21524/pharmacy
        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;
            }
        }
コード例 #11
0
ファイル: main_window.cs プロジェクト: isuru21524/pharmacy
        public void useraccountsave()
        {
            dbconnection ab = new dbconnection();

            try
            {
                string query32 = "update useraccounts set type='" + UA_type.Text + "',firstname='" + UA_firstname.Text + "',lastname='" + UA_lastname.Text + "',surname='" + UA_surname.Text + "',nationalid='" + UA_nic.Text + "',dob='" + UA_date.Text + "',mobile='" + UA_mobnumber.Text + "',addressnum='" + UA_addressnum.Text + "',addressstreet='" + UA_addressstreet.Text + "',addresstown='" + UA_addresstown.Text + "' where userid='" + UA_userid.Text + "';";

                ab.openconnection();
                ab.command(query32).ExecuteNonQuery();
                ab.closeconnection();

                dbconnection db = new dbconnection();

                string query30 = "select userid as 'User ID', firstname as 'First Name',lastname as 'Last Name',type as 'Type' from pharmacy.useraccounts;";
                db.openconnection();
                db.command(query30);

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = db.command(query30);
                DataTable dbtab = new DataTable();
                sda.Fill(dbtab);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = dbtab;
                dataGridView2.DataSource = bsourse;
                sda.Update(dbtab);

                db.closeconnection();


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

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

                dataGridView2.Enabled = true;

                MessageBox.Show("Saving succesfull!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #12
0
ファイル: newitem_window.cs プロジェクト: isuru21524/pharmacy
        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());
            }
        }
コード例 #13
0
        private void button_createnew_Click(object sender, EventArgs e)
        {
            try
            {
                int    uidz    = Int32.Parse(text_uid.Text);
                string fname   = text_firstname.Text;
                string lname   = text_lastname.Text;
                string surname = text_surname.Text;
                string date    = text_date.Text;
                string nic     = text_nicnumber.Text;
                string mobile  = text_mnumber.Text;
                string add1    = text_addnum.Text;
                string add2    = text_addstreet.Text;
                string add3    = text_addtown.Text;


                dbconnection db      = new dbconnection();
                string       query76 = "insert into customer values('" + uidz + "','" + fname + "','" + lname + "','" + surname + "','" + date + "','" + nic + "','" + mobile + "','" + add1 + "','" + add2 + "','" + add3 + "');";
                db.openconnection();
                db.command(query76).ExecuteNonQuery();
                db.closeconnection();

                int oldid = 0;
                oldid = uidz - 1;

                db.openconnection();
                string query77 = "update lastthings set cusid='" + uidz + "' where cusid='" + oldid + "';";
                db.command(query77).ExecuteNonQuery();
                db.closeconnection();

                customer_window_Load(sender, e);


                text_uid.Clear();
                text_firstname.Clear();
                text_lastname.Clear();
                text_surname.Clear();

                text_nicnumber.Clear();
                text_mnumber.Clear();
                text_addnum.Clear();
                text_addstreet.Clear();
                text_addtown.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #14
0
ファイル: newitem_window.cs プロジェクト: isuru21524/pharmacy
        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);
            }
        }
コード例 #15
0
        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());
            }
        }
コード例 #16
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());
            }
        }
コード例 #17
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());
            }
        }
コード例 #18
0
        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);
            }
        }
コード例 #19
0
        public void savedata()
        {
            try
            {
                dbconnection ac = new dbconnection();

                string querry33 = "insert into useraccounts values('" + text_username.Text + "','" + text_newpassword.Text + "','" + text_type.Text + "','" + Int32.Parse(text_uid.Text) + "','" + text_firstname.Text + "','" + text_lastname.Text + "','" + text_surname.Text + "','" + text_date.Text + "','" + text_nicnumber.Text + "','" + text_mnumber.Text + "','" + text_addnum.Text + "','" + text_addstreet.Text + "','" + text_addtown.Text + "');";

                ac.openconnection();
                ac.command(querry33).ExecuteNonQuery();
                ac.closeconnection();

                int olid = Int32.Parse(text_uid.Text) - 1;

                string query34 = "update lastthings set userid='" + text_uid.Text + "' where userid='" + olid + "';";

                ac.openconnection();
                ac.command(query34).ExecuteNonQuery();
                ac.closeconnection();

                MessageBox.Show("Account created");

                int newid = Int32.Parse(text_uid.Text) + 1;
                text_uid.Text = newid.ToString();

                text_firstname.Text   = "";
                text_lastname.Text    = "";
                text_surname.Text     = "";
                text_nicnumber.Text   = "";
                text_mnumber.Text     = "";
                text_addnum.Text      = "";
                text_addstreet.Text   = "";
                text_addtown.Text     = "";
                text_type.Text        = "";
                text_username.Text    = "";
                text_newpassword.Text = "";
                text_repass.Text      = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #20
0
ファイル: newitem_window.cs プロジェクト: isuru21524/pharmacy
        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();
        }
コード例 #21
0
ファイル: stockform.cs プロジェクト: isuru21524/pharmacy
        private void stockform_Load(object sender, EventArgs e)
        {
            dbconnection db = new dbconnection();



            String query8 = "select productid as 'Product_ID',productname as 'Product_Name',quantity as 'Quantity',buyprice as 'Buying_Price',sellprice as 'Selling_Price',suppliers as 'Supplier',type as 'Type' from pharmacy.stock;";

            db.openconnection();
            db.command(query8);

            try
            {
                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = db.command(query8);
                DataTable dbtab = new DataTable();
                sda.Fill(dbtab);
                BindingSource bsourse = new BindingSource();

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

                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.White;

                dataGridView1.EnableHeadersVisualStyles = false;
                dataGridView1.ColumnHeadersBorderStyle  = DataGridViewHeaderBorderStyle.None;
                dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = Color.FromArgb(20, 25, 72);
                dataGridView1.ColumnHeadersDefaultCellStyle.ForeColor = Color.White;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
コード例 #22
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());
            }
        }
コード例 #23
0
ファイル: main_window.cs プロジェクト: isuru21524/pharmacy
        public void dataview()
        {
            dbconnection db = new dbconnection();

            string query30 = "select userid as 'User ID', firstname as 'First Name',lastname as 'Last Name',type as 'Type' from pharmacy.useraccounts;";

            db.openconnection();
            db.command(query30);

            MySqlDataAdapter sda = new MySqlDataAdapter();

            sda.SelectCommand = db.command(query30);
            DataTable dbtab = new DataTable();

            sda.Fill(dbtab);
            BindingSource bsourse = new BindingSource();

            bsourse.DataSource       = dbtab;
            dataGridView2.DataSource = bsourse;
            sda.Update(dbtab);

            db.closeconnection();


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

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

            dataGridView2.Enabled = true;
        }
コード例 #24
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());
            }
        }
コード例 #25
0
        private void text_stock_serchbox_TextChanged(object sender, EventArgs e)
        {
            string keyword = text_stock_serchbox.Text;

            if (keyword != null)
            {
                String       query9 = "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 where customerid like '%" + keyword + "%' or firstname like '%" + keyword + "%' or lastname like '%" + keyword + "%' or surname like '%" + keyword + "%'  ;";
                dbconnection dbs    = new dbconnection();
                dbs.openconnection();

                MySqlDataAdapter sda = new MySqlDataAdapter();
                sda.SelectCommand = dbs.command(query9);
                DataTable dbtab = new DataTable();
                sda.Fill(dbtab);
                BindingSource bsourse = new BindingSource();

                bsourse.DataSource       = dbtab;
                dataGridView1.DataSource = bsourse;
                sda.Update(dbtab);
            }
            else
            {
            }
        }
コード例 #26
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());
            }
        }
コード例 #27
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");
            }
        }
コード例 #28
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());
            }
        }
コード例 #29
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());
                }
            }
        }
コード例 #30
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());
            }
        }