Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int    itemId = int.Parse(textBox1.Text);
            int    count  = int.Parse(textBox3.Text);
            string loc    = (String)comboBox1.SelectedItem;
            string floc   = (String)comboBox3.SelectedItem;
            String name   = textBox1.Text;
            String ttype  = "Issue";

            String datenw = DateTime.Now.ToString();

            string qry = "Select * from inventory where item_id='" + itemId + "';";

            MySqlConnection connst = new MySqlConnection("server=localhost;user id=root;database=harasara");
            MySqlCommand    cmd1   = new MySqlCommand(qry, connst);
            MySqlDataReader reader;


            connst.Open();
            reader = cmd1.ExecuteReader();
            while (reader.Read())
            {
                Int32 rolt = reader.GetInt32("rol");

                Int32 countt = reader.GetInt32("count");
                //float pricet = reader.GetFloat("price");
                if (countt >= rolt)
                {
                    Int32 countf = countt - count;
                    //float pricef = (pricet + price) / 2;



                    try
                    {
                        String    qry2 = "Insert into inv_trans(item_id,count,location,type,factory,date) values('" + itemId + "','" + count + "','" + loc + "','" + ttype + "','" + floc + "','" + datenw + "')";
                        String    qry1 = "Update inventory set count='" + countf + "',last_update='" + datenw + "' where (item_id='" + itemId + "'or name='" + name + "')and location='" + loc + "'";
                        dbconnect conn = new dbconnect();

                        conn.ExQuery(qry1);
                        conn.ExQuery(qry2);

                        MessageBox.Show("Entry Added Success");
                        textBox1.Text = "";
                        textBox2.Text = "";
                        textBox3.Text = "";
                        //textBox4.Text = "";
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Check database connection");
                    }
                }
                else
                {
                    MessageBox.Show("Low Inventory Unable to Issue");
                }
            }
        }
Ejemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            dbconnect dbcon = new dbconnect();

            String loc  = (String)comboBox2.SelectedItem;
            String qry3 = "SELECT * from inventory_fd where location='" + loc + "' ";

            BindingSource bsource = new BindingSource();

            bsource.DataSource = dbcon.ReadValue(qry3);

            dataGridView2.DataSource = bsource;
        }
Ejemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            String stadate = dateTimePicker1.Text;
            String enddate = dateTimePicker2.Text;
            String loc     = (String)comboBox4.SelectedItem;
            String typ     = (String)comboBox3.SelectedItem;

            dbconnect dbcon = new dbconnect();

            String qry1 = "SELECT * FROM fd_trans WHERE location='" + loc + "' AND type='" + typ + "' AND Date BETWEEN '" + stadate + "' AND '" + enddate + "' ";

            BindingSource bsource = new BindingSource();

            bsource.DataSource       = dbcon.ReadValue(qry1);
            dataGridView3.DataSource = bsource;
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            String prodid   = textBox1.Text;
            int    count    = int.Parse(textBox2.Text);
            String loc      = (String)comboBox1.SelectedItem;
            String typet    = "Receipt";
            String datenw   = DateTime.Today.Date.ToString("yyyy-MM-dd");
            String prodname = (String)textBox5.Text;

            String qry = "Select * from inventory_fd where productID='" + prodid + "'";

            MySqlConnection connst = new MySqlConnection("server=localhost;user id=root;database=harasara");
            MySqlCommand    cmd1   = new MySqlCommand(qry, connst);
            MySqlDataReader reader;

            connst.Open();
            reader = cmd1.ExecuteReader();

            reader.Read();
            Int32 countt = reader.GetInt32("Count");
            Int32 countf = countt + count;

            try
            {
                String    qry2 = "Insert into fd_trans(productID,productName,count,location,type,date) values('" + prodid + "','" + prodname + "','" + count + "','" + loc + "','" + typet + "','" + datenw + "')";
                String    qry1 = "Update inventory_fd set count='" + countf + "' where productID='" + prodid + "'and location='" + loc + "'";
                dbconnect conn = new dbconnect();

                conn.ExQuery(qry1);
                conn.ExQuery(qry2);

                textBox1.Text = "";
                textBox2.Text = "";

                MessageBox.Show("Success", "Stock Added Successfully", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Check database connection");
            }
            finally
            {
                MessageBox.Show("");
            }
        }