Exemple #1
0
        private void pro_id_TextChanged(object sender, EventArgs e)
        {
            try{
                DBConnect connection = new DBConnect();
                connection.OpenConnection();

                MySqlConnection returnConn = new MySqlConnection();
                returnConn = connection.GetConnection();

                string       query = "SELECT * FROM products WHERE productId = '" + pro_id.Text + "'";
                MySqlCommand cmd   = new MySqlCommand(query, returnConn);


                using (MySqlDataReader read = cmd.ExecuteReader())
                {
                    while (read.Read())
                    {
                        pro_name.Text = read.GetString("name").ToString();
                        //txt_amound.Text = read.GetString().ToString();
                    }
                }
            }

            catch (Exception ex)
            {
                MetroMessageBox.Show(this.MdiParent, ex.Message);

                //MessageBox.Show(ex.Message);
            }
            try
            {
                DBConnect connection = new DBConnect();
                connection.OpenConnection();

                MySqlConnection returnConn = new MySqlConnection();
                returnConn = connection.GetConnection();



                string       query1 = "SELECT * FROM inv_newitems WHERE productId = '" + pro_id.Text + "'";
                MySqlCommand cmd1   = new MySqlCommand(query1, returnConn);


                using (MySqlDataReader read = cmd1.ExecuteReader())
                {
                    while (read.Read())
                    {
                        pro_amound.Text = read.GetString("MaximumRetailPrice").ToString();
                    }
                }
            }

            catch (Exception ex)
            {
                MetroMessageBox.Show(this.MdiParent, ex.Message);

                //MessageBox.Show(ex.Message);
            }

            try
            {
                DBConnect connection = new DBConnect();
                connection.OpenConnection();

                MySqlConnection returnConn = new MySqlConnection();
                returnConn = connection.GetConnection();

                string       query1 = "SELECT * FROM available WHERE productID = '" + pro_id.Text + "'";
                MySqlCommand cmd1   = new MySqlCommand(query1, returnConn);

                using (MySqlDataReader read = cmd1.ExecuteReader())
                {
                    while (read.Read())
                    {
                        quantityy.Text = read.GetString("Total").ToString();
                    }
                }
            }

            catch (Exception ex)
            {
                MetroMessageBox.Show(this.MdiParent, "ex");
                //MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (txt_receiveddate.Text != "" && batchno.Text != "" && productid.Text != "" && manufactureddate.Text != "" && expireddate.Text != "" && textBox1.Text != "" && priceperunit.Text != "" && quantity.Text != "")
            {
                // string id = txt_id.Text;
                string receivedate = txt_receiveddate.Value.ToString("yyyy-MM-dd");

                string Batchno          = batchno.Text;
                string Productid        = productid.Text;
                string Manufactureddate = manufactureddate.Value.ToString("yyyy-MM-dd");
                string Expireddate      = expireddate.Value.ToString("yyyy-MM-dd");
                string Productname      = textBox1.Text;
                string Priceperunit     = priceperunit.Text;
                string Quantity         = quantity.Text;
                string Box       = box.Text;
                string Packet    = packet.Text;
                string UnitPrice = unitprice.Text;

                try
                {
                    DBConnect conn = new DBConnect();
                    conn.OpenConnection();
                    MySqlConnection returnConn = new MySqlConnection();
                    returnConn = conn.GetConnection();

                    string       query = ("insert into inv_newitems (ReceivedDate,BatchNo,ManufacturedDate,ExpiredDate,ProductID,ProductName,Quantity,MaximumRetailPrice,UnitPrice,Packed) values(@receiveddate,@batchno,@manufactureddate,@expireddate,@productid,@productname,@quantity,@ppunit,@unitpp,@packed)");
                    MySqlCommand cmd   = new MySqlCommand(query, returnConn);

                    //cmd.Parameters.AddWithValue("@id", id);
                    cmd.Parameters.AddWithValue("@receiveddate", receivedate);
                    cmd.Parameters.AddWithValue("@batchno", Batchno);
                    cmd.Parameters.AddWithValue("@productid", Productid);
                    cmd.Parameters.AddWithValue("@manufactureddate", Manufactureddate);
                    if (manufactureddate.Value != expireddate.Value)
                    {
                        cmd.Parameters.AddWithValue("@expireddate", Expireddate);
                    }
                    else
                    {
                        MetroMessageBox.Show(this.MdiParent, "Manufactured Date and Expired Date can't Be Same");

                        return;
                    }
                    if (manufactureddate.Value > expireddate.Value)
                    {
                        MetroMessageBox.Show(this.MdiParent, "Expired Date Should Be Future Date of Manufacture Date");

                        return;
                    }

                    cmd.Parameters.AddWithValue("@productname", Productname);
                    cmd.Parameters.AddWithValue("@quantity", Quantity);
                    cmd.Parameters.AddWithValue("@ppunit", Priceperunit);
                    cmd.Parameters.AddWithValue("@unitpp", UnitPrice);

                    if (box.Checked == true)
                    {
                        cmd.Parameters.AddWithValue("@packed", Box);
                    }
                    else if (packet.Checked == true)
                    {
                        cmd.Parameters.AddWithValue("@packed", Packet);
                    }
                    //cmd.Parameters.AddWithValue("@packed", packet.Text);
                    cmd.ExecuteNonQuery();
                    conn.CloseConnection();

                    MetroMessageBox.Show(this.MdiParent, "Added Successfully");

                    DisplayData();
                    ClearData();
                }
                catch (Exception ex)
                {
                    MetroMessageBox.Show(this.MdiParent, ex.Message);
                }
            }
            else
            {
                MetroMessageBox.Show(this.MdiParent, "Insert Values");
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (pro_id.Text != "" && pro_name.Text != "" && pro_quantity.Text != "" && pro_amound.Text != "")
            {
                try
                {
                    if (status.Text == "Approved")
                    {
                        //MessageBox.Show(pro_quantity.Text);
                        // MessageBox.Show(quantityy.Text);


                        if ((pro_id.Text != "" && pro_name.Text != "" && pro_quantity.Text != "" && pro_amound.Text != ""))
                        {
                            // MessageBox.Show("if success");
                            try
                            {
                                DBConnect connection = new DBConnect();
                                connection.OpenConnection();
                                MySqlConnection returnConn = new MySqlConnection();
                                returnConn = connection.GetConnection();
                                string query;

                                query = "INSERT INTO inv_inventoryout (orderid, orderdate, deliverydate, productid, productname, quantity, unitprice, status) VALUES (@1, @2, @3, @4, @5, @6, @7, @8)";
                                //query = "insert into inv_inventoryout(orderid,orderdate,deliverydate,productid,productname,quantity,unitprice,status) values (@1,@2,@3,@4,@5,@6,@7,@8)";
                                MySqlCommand cmd = new MySqlCommand(query, returnConn);

                                cmd.Parameters.AddWithValue("@1", txitid.Text);
                                cmd.Parameters.AddWithValue("@2", date_order.Value.ToString("yyyy/MM/dd"));
                                cmd.Parameters.AddWithValue("@3", date_delivery.Value.ToString("yyyy/MM/dd"));
                                cmd.Parameters.AddWithValue("@4", pro_id.Text);
                                cmd.Parameters.AddWithValue("@5", pro_name.Text);
                                cmd.Parameters.AddWithValue("@6", Convert.ToInt32(pro_quantity.Text));
                                cmd.Parameters.AddWithValue("@7", Convert.ToInt32(pro_amound.Text));
                                cmd.Parameters.AddWithValue("@8", status.Text);

                                cmd.ExecuteNonQuery();
                                MetroMessageBox.Show(this.MdiParent, "Record Updated Sucessfully!");
                                int quantity1 = Int32.Parse(pro_quantity.Text);
                                int quantity2 = Int32.Parse(quantityy.Text);

                                int quantity3 = quantity2 - quantity1;
                                //MessageBox.Show("Converted");

                                if (quantity3 < 0)
                                {
                                    MetroMessageBox.Show(this.MdiParent, "Not Having Enough Quantity! Sent a Work Order Request");
                                    //invoice();
                                }
                                connection.CloseConnection();
                                invoice();

                                DisplayData();
                                ClearData();
                            }
                            catch (Exception ex)
                            {
                                MetroMessageBox.Show(this, ex.Message);
                            }
                        }
                        else
                        {
                            MetroMessageBox.Show(this.MdiParent, "Select the Field to Update");
                        }
                    }
                }
                catch (Exception ex)
                {
                    MetroMessageBox.Show(this.MdiParent, ex.Message);
                }
            }
        }