Exemple #1
0
        public bool insertKHForQL(string maKH, string tenKH, string gender, string address, string phone, string TP, DateTime ngayBD, MemoryStream picture)
        {
            My_DB      mydb    = new My_DB();
            SqlCommand command = new SqlCommand("insert into QLKH(MaKh,TenKH ,GioiTinh,DiaChi,DienThoai,ThuePhong,NgayBatDau,CMND)"
                                                + " Values(@MKH, @tkh, @gt,@adr, @phone,@TP,@date,@pic)", mydb.GetConnection);

            command.Parameters.Add("@MKH", SqlDbType.VarChar).Value   = maKH;
            command.Parameters.Add("@tkh", SqlDbType.NVarChar).Value  = tenKH;
            command.Parameters.Add("@gt", SqlDbType.NVarChar).Value   = gender;
            command.Parameters.Add("@adr", SqlDbType.NVarChar).Value  = address;
            command.Parameters.Add("@phone", SqlDbType.VarChar).Value = phone;
            command.Parameters.Add("@TP", SqlDbType.VarChar).Value    = TP;
            command.Parameters.Add("@date", SqlDbType.DateTime).Value = ngayBD;
            command.Parameters.Add("@pic", SqlDbType.Image).Value     = picture.ToArray();


            mydb.openConnection();
            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Exemple #2
0
        public bool deleteBaoCao(int id)
        {
            SqlCommand command = new SqlCommand("DELETE FROM BaoCaoNgay WHERE Id = @Id", mydb.GetConnection);

            command.Parameters.Add("@Id", SqlDbType.Int).Value = id;
            mydb.openConnection();
            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Exemple #3
0
        public bool insertNhanVien(int id, string fname, string lname, DateTime bdate, string gender, string phone, string address, MemoryStream picture, int CaLamViec)
        {
            SqlCommand command = new SqlCommand("insert into TTNV(IdNhanVien , Fname, Lname, Bdate, Gender, Phone, Address, Picture,CaLamViec)"
                                                + " Values(@id, @fn, @ln,@bdt, @gdr, @phn, @adrs, @pic,@Ca)", mydb.GetConnection);

            command.Parameters.Add("@id", SqlDbType.Int).Value        = id;
            command.Parameters.Add("@fn", SqlDbType.NVarChar).Value   = fname;
            command.Parameters.Add("@ln", SqlDbType.NVarChar).Value   = lname;
            command.Parameters.Add("@bdt", SqlDbType.DateTime).Value  = bdate;
            command.Parameters.Add("@gdr", SqlDbType.NVarChar).Value  = gender;
            command.Parameters.Add("@phn", SqlDbType.NVarChar).Value  = phone;
            command.Parameters.Add("@adrs", SqlDbType.NVarChar).Value = address;
            command.Parameters.Add("@pic", SqlDbType.Image).Value     = picture.ToArray();
            command.Parameters.Add("@Ca", SqlDbType.Int).Value        = CaLamViec;


            mydb.openConnection();
            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Exemple #4
0
        public bool updateTPhong(string maP)
        {
            My_DB      mydb    = new My_DB();
            SqlCommand command = new SqlCommand("UPDATE TTPhong SET TrangThai = @TP where MaPhong = @mp", mydb.GetConnection);

            command.Parameters.Add("@TP", SqlDbType.Int).Value     = 0;
            command.Parameters.Add("@mp", SqlDbType.VarChar).Value = maP;
            mydb.openConnection();
            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Exemple #5
0
        public bool updateNGayKTForQL(string MAKH, DateTime NgayKT)
        {
            SqlCommand command = new SqlCommand("UPDATE QLKH SET NgayKetThuc = @NKT WHERE MaKH = @Ma", mydb.GetConnection);

            command.Parameters.Add("@Ma", SqlDbType.VarChar).Value   = MAKH;
            command.Parameters.Add("@NKT", SqlDbType.DateTime).Value = NgayKT;

            mydb.openConnection();
            if ((command.ExecuteNonQuery() == 1))
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
Exemple #6
0
        private void ButtonLogin_Click(object sender, EventArgs e)
        {
            Nhanvien nv = new Nhanvien();
            My_DB    db = new My_DB();

            db.openConnection();
            try
            {
                SqlCommand command = new SqlCommand("SELECT * FROM Login WHERE UserName = @User AND PassWord = @Pass ", db.GetConnection);
                command.Parameters.Add("@User", SqlDbType.VarChar).Value = TextBoxUser.Text;
                command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = TextBoxPassword.Text;

                SqlDataAdapter adapter = new SqlDataAdapter(command);
                DataTable      table   = new DataTable();
                adapter.SelectCommand = command;
                adapter.Fill(table);
                SqlCommand command2 = new SqlCommand("Select ChucVu From Login where UserName like '" + TextBoxUser.Text + "%'");
                DataTable  table2   = nv.getLaoCong(command2);
                string     ChucVu   = (string)table2.Rows[0]["ChucVu"];
                SqlCommand command3 = new SqlCommand("Select Id From Login where UserName like '" + TextBoxUser.Text + "%'");
                DataTable  table3   = nv.getLaoCong(command3);
                int        Id       = (int)table3.Rows[0]["Id"];
                if (ChucVu == "LaoCong   ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        LaoCong str = new LaoCong();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else if (ChucVu == "LeTan     ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        LeTan str = new LeTan();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else if (ChucVu == "QuanLy    ")
                {
                    if (table.Rows.Count > 0)
                    {
                        Global.SetGlobalUserId(Id);
                        Quan_ly str = new Quan_ly();
                        this.Hide();
                        str.ShowDialog();
                        this.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Username or Password");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Username or Password");
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Invalid Username or Password ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }