Пример #1
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            if (tb_Password.Text == tb_C_Password.Text)
            {
                obj.openconnection();
                obj.cmd = new SqlCommand("insert into Login Values ( '" + tb_Username.Text + "' , '" + tb_Password.Text + "' ) ", obj.con);

                if (Convert.ToInt32(obj.cmd.ExecuteNonQuery()) > 0)
                {
                    MessageBox.Show("User Added Succefully...");
                    obj.cmd.Dispose();
                    obj.closeconnection();
                    obj.ClearTextBoxes(this);
                }
                else
                {
                    MessageBox.Show("ReEnter Correct Password...");
                }
            }
        }
        private void btn_delete_row_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = MessageBox.Show("Do you want to delete these entry...?", "Confirmation", MessageBoxButtons.YesNoCancel);
                if (result == DialogResult.Yes)
                {
                    //...
                    SqlDataReader dr;
                    Common_Class  obj = new Common_Class();
                    obj.openconnection();


                    int i;
                    i = dgv_cust_master.SelectedCells[0].RowIndex;

                    obj.cmd = new SqlCommand("Select * from Customer_Master where Customer_ID = " + dgv_cust_master.SelectedRows[i].Cells[0].Value.ToString() + " ", obj.con);

                    dr = obj.cmd.ExecuteReader();
                    if (dr.Read())
                    {
                        tempid = (int)dr["Customer_ID"];
                        dr.Close();
                    }
                    obj.cmd = new SqlCommand("Delete from Customer_Purchase_Detail where Customer_ID = " + tempid + " ", obj.con);
                    obj.cmd.ExecuteNonQuery();

                    obj.cmd = new SqlCommand("Delete from Customer_Master where Customer_ID = " + tempid + " ", obj.con);
                    if (obj.cmd.ExecuteNonQuery() > 0)
                    {
                        MessageBox.Show("Row Deleted");
                        // TODO: This line of code loads data into the 'mobile_Shoppee_DBDataSet.Customer_Purchase_Detail' table. You can move, or remove it, as needed.
                        this.customer_Purchase_DetailTableAdapter.Fill(this.mobile_Shoppee_DBDataSet.Customer_Purchase_Detail);
                        // TODO: This line of code loads data into the 'mobile_Shoppee_DBDataSet.Customer_Master' table. You can move, or remove it, as needed.
                        this.customer_MasterTableAdapter.Fill(this.mobile_Shoppee_DBDataSet.Customer_Master);
                    }
                    else
                    {
                        MessageBox.Show("Record Are Not Deleted");
                    }
                    obj.closeconnection();
                    obj.cmd.Dispose();
                    dr.Close();
                }
            }
            catch (Exception ex)
            {
                //  Block of code to handle errors
                MessageBox.Show(ex.Message);
            }
        }
Пример #3
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (tb_Total_Bill.Text != "")
                {
                    obj.openconnection();
                    obj.globalVal_Custid(0, int.Parse(tb_Customer_ID.Text));
                    obj.cmd = new SqlCommand(" insert into Customer_Master values (" + tb_Customer_ID.Text + " , '" + tb_Customer_Name.Text + "' , '" + dtp_Bill_Date.Text + "' , " + tb_Customer_Mob_No.Text + ",'" + tb_Cust_GSTIN.Text + "' , " + tb_Bill.Text + " , " + tb_Discount.Text + " , " + tb_Total_Bill.Text + " )", obj.con);

                    if (obj.cmd.ExecuteNonQuery() > 0)
                    {
                        goto nxtquery;
                    }
                    else
                    {
                        MessageBox.Show("Record are Not saved Successfully");
                    }
                    nxtquery :;
                    obj.cmd.Dispose();

                    int i = 0;
                    foreach (DataGridViewRow row in dgv_new_bill.Rows)
                    {
                        if (i == (dgv_new_bill.Rows.Count - 1))
                        {
                            goto nxt;
                        }
                        //  int Mob_id = 0;
                        obj.cmd = new SqlCommand(" Insert into Customer_Purchase_Detail values(" + dgv_new_bill.Rows[i].Cells[0].Value + ",'" + dgv_new_bill.Rows[i].Cells[1].Value + "','" + dgv_new_bill.Rows[i].Cells[2].Value + "','" + dgv_new_bill.Rows[i].Cells[3].Value + "'," + dgv_new_bill.Rows[i].Cells[4].Value + "," + dgv_new_bill.Rows[i].Cells[5].Value + "," + dgv_new_bill.Rows[i].Cells[6].Value + " ," + dgv_new_bill.Rows[i].Cells[7].Value + "," + dgv_new_bill.Rows[i].Cells[8].Value + "," + dgv_new_bill.Rows[i].Cells[9].Value + "," + dgv_new_bill.Rows[i].Cells[10].Value + " )", obj.con);
                        obj.cmd.ExecuteNonQuery();
                        obj.cmd.Dispose();

                        i = i + 1;
                    }
                    nxt :;

                    if (i > 0)
                    {
                        //obj.globalVal_Custid(0,int.Parse(tb_Customer_ID.Text));

                        MessageBox.Show("Record Added Successfully...");

                        frm_Bill_History_by_Cust_Name obj1 = new frm_Bill_History_by_Cust_Name();
                        obj1.Show();
                    }
                    else
                    {
                        MessageBox.Show("Server Error..");
                    }

                    tb_Customer_Name.Text   = "";
                    tb_Customer_Mob_No.Text = "";
                    tb_Bill.Text            = "";
                    tb_Discount.Text        = "0";
                    tb_Price.Text           = "";
                    tb_Quantity.Text        = "";
                    tb_Total_Bill.Text      = "";
                    tb_Customer_Mob_No.Text = "";
                    cb_Brand_Name.Text      = "";
                    cb_Model_Name.Text      = "";
                    tb_Total_Price.Text     = "";
                    dgv_new_bill.DataSource = "";

                    int f = 0;
                    f = obj.Auto_Increment("select count(Customer_ID) from Customer_Master", 1);
                    tb_Customer_ID.Text = Convert.ToString(f);
                }
                else
                {
                    MessageBox.Show("Please fill all fields");
                }
            }
            catch (Exception ex)
            {
                //  Block of code to handle errors
                MessageBox.Show(ex.Message);
            }
        }