예제 #1
0
        private void bntback1_Click(object sender, EventArgs e)
        {
            sale s = new sale();

            s.Show();
            this.Visible = false;
        }
예제 #2
0
        private void Sale_Click(object sender, EventArgs e)
        {
            sale sl = new sale();

            sl.Show();
            this.Visible = false;
        }
예제 #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox4.Text == "")
            {
                MessageBox.Show("Please Complete form filling ...");
            }
            else
            {
                double D = 0, kh = 0, cb;
                D  += Convert.ToDouble(textBox7.Text);
                kh += Convert.ToDouble(textBox8.Text) / 4000;
                cb  = (D + kh) - Convert.ToDouble(textBox2.Text);
                if (cb >= 0)
                {
                    try
                    {
                        DataCon.ConnectionDB("ENDROX", "BookStore");

                        int           dindex, x;
                        float         y;
                        string        sql = "select bid, bqty from Book where bid ='" + textBox16.Text + "'";
                        SqlCommand    a   = new SqlCommand(sql, DataCon.DataConnection);
                        SqlDataReader r   = a.ExecuteReader();
                        while (r.Read())
                        {
                            string id = r.GetValue(0) + "";
                            dindex         = Convert.ToInt16(id);
                            textBox14.Text = dindex + "";

                            string idx = r.GetValue(1) + "";
                            x = Convert.ToInt16(idx);
                            textBox15.Text = x + "";
                        }
                        r.Close();

                        int    indexx = Convert.ToInt16(textBox1.Text);
                        double gtotal = Convert.ToDouble(textBox2.Text);
                        int    eid    = Convert.ToInt16(textBox4.Text);
                        sql = "insert into Sale(saleid,saledate, samount, eid) values ('" + indexx + "',N'" + dateTimePicker1.Text + "','" + gtotal + "','" + eid + "');";
                        SqlCommand s = new SqlCommand(sql, DataCon.DataConnection);
                        s.ExecuteNonQuery();
                        s.Dispose();

                        int ro = dataGridView1.RowCount - 1;
                        for (int i = 0; i < ro; i++)
                        {
                            sql = "insert into SaleDetail(saleid,sdqty, sdprice, sdtotal, bid) values ('" + indexx + "','" + Convert.ToInt16(dataGridView1.Rows[i].Cells["Quantity"].Value) + "','" + Convert.ToSingle(dataGridView1.Rows[i].Cells["Price"].Value) + "','" + Convert.ToSingle(dataGridView1.Rows[i].Cells["totals"].Value) + "','" + dataGridView1.Rows[i].Cells["Book_Code"].Value + "');";
                            SqlCommand si = new SqlCommand(sql, DataCon.DataConnection);
                            si.ExecuteNonQuery();

                            int nbqty = Convert.ToInt16(textBox15.Text) - Convert.ToInt16(dataGridView1.Rows[i].Cells["Quantity"].Value);
                            sql = "update Book set bqty ='" + nbqty + "' where bid = '" + textBox16.Text + "' ;";
                            SqlCommand sa = new SqlCommand(sql, DataCon.DataConnection);
                            sa.ExecuteNonQuery();
                        }
                        string message = "Cashback = " + cb + "";
                        string title   = " Message ";
                        MessageBox.Show(message, title);

                        message = "Successfully Saved";
                        title   = " Message ";
                        MessageBox.Show(message, title);


                        textBox2.Text         = "";
                        dateTimePicker1.Value = System.DateTime.Now;
                        dataGridView1.Rows.Clear();
                        textBox6.Text  = "";
                        textBox10.Text = "";
                        textBox11.Text = "";

                        Visible = false;
                        sale sl = new sale();
                        sl.Show();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                else
                {
                    string message = "Need " + cb + " to Complete the Payment";
                    string title   = " Message ";
                    MessageBox.Show(message, title);
                }
            }
        }