コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty || textBox2.Text == " " || textBox3.Text == string.Empty || textBox4.Text == " ")

            {
                MessageBox.Show("Please fill all the required fields");
            }
            else
            {
                try
                {
                    {
                        Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
                        DateTime date     = DateTime.Parse(dateTimePicker1.Text);
                        int      age      = int.Parse(textBox2.Text);
                        bool     employee = db.employee(textBox1.Text, age, textBox3.Text, date, textBox4.Text);

                        MessageBox.Show("Record Added Successfully");
                        textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear();
                        show();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Database Error", "Error Code 1", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == string.Empty || textBox2.Text == string.Empty || textBox3.Text == string.Empty)
     {
         MessageBox.Show("Please fill all the required fields");
     }
     else
     {
         Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
         bool customer = db.supplier(textBox1.Text, textBox2.Text, textBox3.Text);
         MessageBox.Show("Record Added Successfully");
         textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear();
         show();
     }
 }
コード例 #3
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == string.Empty)
     {
         MessageBox.Show("Please fill the required field");
     }
     else
     {
         {
             Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
             bool catogry = db.catogry(textBox1.Text);
             show();
             textBox1.Clear();
         }
     }
 }
コード例 #4
0
 private void add()
 {
     if (textBox7.Text == string.Empty || textBox3.Text == string.Empty || textBox4.Text == string.Empty || textBox5.Text == string.Empty)
     {
         MessageBox.Show("Please fill all the required fields");
     }
     else
     {
         {
             int      d1  = int.Parse(textBox3.Text);
             float    d2  = float.Parse(textBox4.Text);
             float    d3  = float.Parse(textBox5.Text);
             DateTime dt1 = DateTime.Parse(dateTimePicker1.Text);
             Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
             bool stock = db.stock(textBox7.Text, comboBox1.Text, d1, d2, d3, dt1);
             textBox3.Clear(); textBox7.Clear(); textBox4.Clear(); textBox5.Clear();
             show();
         }
     }
 }
コード例 #5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == string.Empty || textBox2.Text == string.Empty)
     {
         MessageBox.Show("Please fill the required fields");
     }
     else
     {
         try
         {
             Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
             bool product = db.product(comboBox1.Text, comboBox2.Text, textBox1.Text, textBox2.Text);
             MessageBox.Show("Record Added Successfully");
             show();
             comboBox1.Text = ""; comboBox2.Text = ""; textBox1.Clear(); textBox2.Clear();
         }
         catch (Exception)
         {
             MessageBox.Show("Database Error", "Error Code 5", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #6
0
 public void add()
 {
     if (textBox1.Text == string.Empty)
     {
         MessageBox.Show("Please fill all the required field");
     }
     else
     {
         try
         {
             {
                 DateTime dt1 = DateTime.Parse(dateTimePicker1.Text);
                 Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
                 bool opeaning = db.opeaning(dt1, textBox1.Text);
                 textBox1.Clear();
                 show();
             }
         }
         catch (Exception)
         {
             MessageBox.Show("Database Error", "Error Code 9", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
コード例 #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            //    label5.Text = incomeing;
            try
            {
                string path         = Path.GetFullPath(Environment.CurrentDirectory);
                string databaseName = "pharma.mdf";
                using (SqlConnection con = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLOCALDB;AttachDbFilename=" + path + @"\" + databaseName + ";Integrated Security=True"))
                {
                    decimal        quantity = 0;
                    DataTable      dt       = new DataTable();
                    string         sql      = "Select Quantity from stock Where Product_name= '" + comboBox1.Text + "'";
                    SqlCommand     cmd      = new SqlCommand(sql, con);
                    SqlDataAdapter adapter  = new SqlDataAdapter(cmd);
                    con.Open();
                    adapter.Fill(dt);
                    quantity = Decimal.Parse(dt.Rows[0]["Quantity"].ToString());
                    int choiceyouhave = int.Parse(textBox3.Text);
                    int youdemand     = int.Parse(textBox5.Text);

                    if (youdemand > choiceyouhave)
                    {
                        MessageBox.Show("Quantity is low");
                    }
                    else
                    {
                        choiceyouhave = choiceyouhave - youdemand;
                        string     sql2 = "update stock set Quantity=@Quantity where Product_name=@Product_name";
                        SqlCommand cmd2 = new SqlCommand(sql2, con);
                        cmd2.Parameters.AddWithValue("@Quantity", choiceyouhave);
                        cmd2.Parameters.AddWithValue("@Product_name", comboBox1.Text);
                        cmd2.ExecuteNonQuery();
                        con.Close();
                        //  cal();
                        int   d1 = int.Parse(textBox5.Text);
                        float d2 = float.Parse(textBox2.Text);
                        Pharmacy_Yasir.Add_user_Database db = new Add_user_Database();
                        bool stock = db.receipt(textBox9.Text, comboBox2.Text, comboBox1.Text, d2, d1);

                        cal();
                    }
                }



                {
                    SqlConnection con1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLOCALDB;AttachDbFilename=" + path + @"\" + databaseName + ";Integrated Security=True");
                    DataTable     dt   = new DataTable();
                    con1.Open();
                    SqlDataReader myReader = null;


                    SqlCommand myCommand = new SqlCommand("select stock.Selling_price_perunit,stock.Quantity from stock INNER JOIN product ON product.s_id=product.s_id where stock.Product_name= '" + comboBox1.Text + "'", con1);

                    myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        textBox2.Text = (myReader["Selling_price_perunit"].ToString());
                        textBox3.Text = (myReader["Quantity"].ToString());
                    }

                    con1.Close();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Fill the required fields", "Error Code 5", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }