Exemple #1
0
        private void managerDriverToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmDrivers driver = new frmDrivers();

            driver.Show();
            this.Hide();
        }
Exemple #2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            SqlConnection conn = connect.Getconect();

            conn.Open();
            //if(txtAdd.Text=="" || txtDrivercode.Text=="" || txtDrivername.Text==""||txtTelephone.Text=="") {
            //MessageBox.Show("You must enter full information");}
            //else{
            if (rbMale.Checked == true)
            {
                gender = "true";
            }
            //if(txtAdd.Text=="" || txtDrivercode.Text=="" || txtDrivername.Text==""||txtTelephone.Text=="") {
            //MessageBox.Show("You must enter full information");}
            //else{
            string sql = "update tblDrivers set Driver_name='" + txtDrivername.Text + "',DoB='" + dateTimePicker1.Text + "',gender='" + gender + "',address='" + txtAdd.Text + "',telephone='" + txtTelephone.Text + "' where driver_code='" + frmDrivers.Code + "'";

            SqlCommand    cmd = new SqlCommand(sql, conn);
            SqlDataReader sdr = cmd.ExecuteReader();

            MessageBox.Show("Update successfull");
            frmDrivers view = new frmDrivers();

            view.Show();
            this.Dispose();
            //}
        }
Exemple #3
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Dispose();
            frmDrivers view = new frmDrivers();

            view.Show();
        }
Exemple #4
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string drivercode = txtDrivercode.Text;
            string drivername = txtDrivername.Text;
            string dob        = dateTimePicker1.Text;
            string gender;

            if (rbMale.Checked == true)
            {
                gender = "1";
            }
            else
            {
                gender = "0";
            }
            string   add       = txtAdd.Text;
            string   telephone = txtTelephone.Text;
            DateTime dt1       = dtpRentDate.Value;
            DateTime dt2       = dtpIntendedDate.Value;
            DateTime dt3       = dtpReturnDate.Value;

            if (txtDrivercode.Text != "" && txtDrivername.Text != "" && txtAdd.Text != "" && txtTelephone.Text != "" && txtCarCode.Text != "" && txtCarName.Text != "" && txtUnitPrice.Text != "" && txtRentPrice.Text != "")
            {
                if (DateTime.Compare(dt1, dt2) < 0 && DateTime.Compare(dt1, dt3) < 0)
                {
                    try
                    {
                        SqlConnection conn = connect.Getconect();
                        conn.Open();

                        string     sql = "insert into tblDrivers values ('" + drivercode + "','" + drivername + "','" + dob + "','" + gender + "','" + add + "','" + telephone + "')";
                        SqlCommand cmd = new SqlCommand(sql, conn);
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        SqlConnection conn1 = connect.Getconect();
                        conn1.Open();
                        string     sql1 = "insert into tblCar_Driver values ('" + txtCarCode.Text + "','" + drivercode + "','" + dtpRentDate.Text + "','" + dtpIntendedDate.Text + "','" + dtpReturnDate.Text + "',null,null,null)";
                        SqlCommand cmd1 = new SqlCommand(sql1, conn1);
                        cmd1.ExecuteNonQuery();
                        MessageBox.Show("Add successfull");

                        frmDrivers frm = new frmDrivers();
                        frm.Show();
                        this.Dispose();
                    }
                    catch (SqlException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }


                else
                {
                    MessageBox.Show("Intend date or Return date must greater than Rent date!");
                }
            }
            else
            {
                MessageBox.Show("You must enter full information!");
            }
        }