示例#1
0
        public bool insertCus(string MaKH, string fname, string lname, DateTime bdate
                              , string phone, string address, string cmnd, MemoryStream Ava)
        {
            SqlCommand cmd = new SqlCommand("insert into KhachHang(MaKH,fName,lName,Birthday,Phone,Address,Cmnd,Ava)" +
                                            "values (@makh,@fname,@lname,@bdate,@phone,@add,@cmnd,@ava)", mydb.getConnection);

            cmd.Parameters.Add("@makh", SqlDbType.VarChar).Value   = MaKH;
            cmd.Parameters.Add("@fname", SqlDbType.VarChar).Value  = fname;
            cmd.Parameters.Add("@lname", SqlDbType.VarChar).Value  = lname;
            cmd.Parameters.Add("@bdate", SqlDbType.DateTime).Value = bdate;
            cmd.Parameters.Add("@phone", SqlDbType.VarChar).Value  = phone;
            cmd.Parameters.Add("@add", SqlDbType.VarChar).Value    = address;
            cmd.Parameters.Add("@cmnd", SqlDbType.VarChar).Value   = cmnd;
            cmd.Parameters.Add("@ava", SqlDbType.Image).Value      = Ava.ToArray();

            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#2
0
        public bool insertNhanVien(string manv, string fname, string lname, string gender, DateTime bdate, string phone,
                                   string address, string cmnd, MemoryStream ava, string type)
        {
            SqlCommand cmd = new SqlCommand("insert into NhanVien(MaNV,fName,lName,gender,Birthday,Phone,Address,Cmnd,Ava,type)" +
                                            "values (@makh,@fname,@lname,@gender,@bdate,@phone,@add,@cmnd,@ava,@type)", mydb.getConnection);

            cmd.Parameters.Add("@makh", SqlDbType.VarChar).Value   = manv;
            cmd.Parameters.Add("@fname", SqlDbType.VarChar).Value  = fname;
            cmd.Parameters.Add("@lname", SqlDbType.VarChar).Value  = lname;
            cmd.Parameters.Add("@gender", SqlDbType.VarChar).Value = gender;
            cmd.Parameters.Add("@bdate", SqlDbType.DateTime).Value = bdate;
            cmd.Parameters.Add("@phone", SqlDbType.VarChar).Value  = phone;
            cmd.Parameters.Add("@add", SqlDbType.VarChar).Value    = address;
            cmd.Parameters.Add("@cmnd", SqlDbType.VarChar).Value   = cmnd;
            cmd.Parameters.Add("@ava", SqlDbType.Image).Value      = ava.ToArray();
            cmd.Parameters.Add("@type", SqlDbType.VarChar).Value   = type;

            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#3
0
文件: KhachHang.cs 项目: ysnna/QLXe
        //Them Khach Hang,cần bổ sung biến
        public bool insertCus(string vitri, string loaixe, MemoryStream anhbienso, MemoryStream anhxe,
                              DateTime ngaygui, DateTime giogui, string yeucau)// Cần thêm các biến

        {
            SqlCommand cmd = new SqlCommand("insert into QUANLIXERAVAO (vitri, loaixe, bienso, ava, ngayguixe, gioguixe, timeyeucau)" +
                                            "values(@vitri, @loaixe, @pic, @pic1, @ngaygui, @giogui, @yeucau)", mydb.getConnection); // Cần biến kết nối data base

            cmd.Parameters.Add("@vitri", SqlDbType.VarChar).Value    = vitri;
            cmd.Parameters.Add("@loaixe", SqlDbType.VarChar).Value   = loaixe;
            cmd.Parameters.Add("@pic", SqlDbType.Image).Value        = anhbienso.ToArray();
            cmd.Parameters.Add("@pic1", SqlDbType.Image).Value       = anhxe.ToArray();
            cmd.Parameters.Add("@ngaygui", SqlDbType.DateTime).Value = ngaygui;
            cmd.Parameters.Add("@giogui", SqlDbType.DateTime).Value  = giogui;
            cmd.Parameters.Add("@yeucau", SqlDbType.VarChar).Value   = yeucau;
            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#4
0
文件: LoginForm.cs 项目: ysnna/QLXe
        private void ButtonRegister_Click(object sender, EventArgs e)
        {
            if (chkAdmin.Checked == true)
            {
                MY_DB          db  = new MY_DB();
                SqlCommand     cmm = new SqlCommand("select * from LOGIN", db.getConnection);
                SqlDataAdapter da  = new SqlDataAdapter();
                DataTable      dt  = new DataTable();
                da.SelectCommand = cmm;
                da.Fill(dt);
                int        countRow = dt.Rows.Count;
                SqlCommand cmd      = new SqlCommand("insert into Login (id, username, password)" +
                                                     " values (@id, @user, @pass)", db.getConnection);
                cmd.Parameters.Add("@id", SqlDbType.Int).Value       = countRow;
                cmd.Parameters.Add("@user", SqlDbType.VarChar).Value = txtUsername.Text;
                cmd.Parameters.Add("@pass", SqlDbType.VarChar).Value = txtPassword.Text;

                db.openConnection();
                if (cmd.ExecuteNonQuery() == 1)
                {
                    db.closeConnection();
                }
                else
                {
                    db.closeConnection();
                }
                da.InsertCommand = cmd;
                da.Update(dt);
                MessageBox.Show("Sign up successful", "Adding...", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#5
0
        public bool deleteCus(string vitri)
        {
            SqlCommand cmd = new SqlCommand("delete from QLLAYXE where vitri = @vitri", mydb.getConnection); //**

            cmd.Parameters.Add("@vitri", SqlDbType.VarChar).Value = vitri;
            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#6
0
        //Insert vao bang doanh thu
        public bool insertDoanhThu(string loaixe, DateTime ngaylay, int soluong, int tongtien)
        {
            SqlCommand cmd = new SqlCommand("insert into DOANHTHUGUIXE(loaixe,ngaylay,soluong,tongtien)" +
                                            "values(@loaixe,@ngaylay,@soluong,@tongtien)", mydb.getConnection);

            cmd.Parameters.Add("@loaixe", SqlDbType.NVarChar).Value = loaixe;
            cmd.Parameters.Add("@ngaylay", SqlDbType.Date).Value    = ngaylay;
            cmd.Parameters.Add("@soluong", SqlDbType.Int).Value     = soluong;
            cmd.Parameters.Add("@tongtien", SqlDbType.Int).Value    = tongtien;
            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#7
0
        public bool insertCon(string maHD, string makh, string thoihan
                              , DateTime ngaybatdau, string tien, string note, string type, string userid)
        {
            SqlCommand cmd = new SqlCommand("insert into HopDong(MaHD,MaKH,ThoiHan,NgayBatDau,Tien,note,Type,userid) "
                                            + "values(@mahd,@makh,@thoihan,@ngaybd,@tien,@note,@type,@uid)", mydb.getConnection);

            cmd.Parameters.Add("@mahd", SqlDbType.VarChar).Value    = maHD;
            cmd.Parameters.Add("@makh", SqlDbType.VarChar).Value    = makh;
            cmd.Parameters.Add("@thoihan", SqlDbType.VarChar).Value = thoihan;
            cmd.Parameters.Add("@ngaybd", SqlDbType.DateTime).Value = ngaybatdau;
            cmd.Parameters.Add("@tien", SqlDbType.VarChar).Value    = tien;
            cmd.Parameters.Add("@note", SqlDbType.NVarChar).Value   = note;
            cmd.Parameters.Add("@type", SqlDbType.NVarChar).Value   = type;
            cmd.Parameters.Add("@uid", SqlDbType.VarChar).Value     = userid;

            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }
示例#8
0
        private void btSave_Click(object sender, EventArgs e)
        {
            DataTable dt    = kh.getPhiGuiXe();
            int       count = dt.Rows.Count;
            string    loaixee;

            for (int i = 0; i < count; i++)
            {
                if (i == 0)
                {
                    loaixee = txtXedap.Text;
                }
                else if (i == 1)
                {
                    loaixee = txtXemay.Text;
                }
                else
                {
                    loaixee = txtOto.Text;
                }
                dt.Rows[i][1] = loaixee;
                dt.Rows[i][2] = Convert.ToInt32(loaixee) * 8;
                dt.Rows[i][3] = Convert.ToInt32(dt.Rows[i][2]) * 3;
                dt.Rows[i][4] = Convert.ToInt32(dt.Rows[i][3]) * 2;
                SqlCommand cmd = new SqlCommand("update GIAGUIXE set theogio=@gio, theongay=@ngay, theotuan=@tuan, theothang=@thang where loaixe=@xe ", mydb.getConnection);
                cmd.Parameters.Add("@gio", SqlDbType.VarChar).Value   = dt.Rows[i][1].ToString();
                cmd.Parameters.Add("@ngay", SqlDbType.VarChar).Value  = dt.Rows[i][2].ToString();
                cmd.Parameters.Add("@tuan", SqlDbType.VarChar).Value  = dt.Rows[i][3].ToString();
                cmd.Parameters.Add("@thang", SqlDbType.VarChar).Value = dt.Rows[i][4].ToString();
                cmd.Parameters.Add("@xe", SqlDbType.VarChar).Value    = dt.Rows[i][0].ToString();
                mydb.openConnection();
                if (cmd.ExecuteNonQuery() == 1)
                {
                    mydb.closeConnection();
                }
                else
                {
                    mydb.closeConnection();
                }
                this.Close();
            }
        }
示例#9
0
文件: KhachHang.cs 项目: ysnna/gd2QLX
        //public bool updatePhiGuiXe(string xedap, string xemay, string oto)
        public bool updateBaiXe(string num, string vitri)
        {
            SqlCommand cmd = new SqlCommand("update BAIXE set khuA=@num where vitriXe=@vitri ", mydb.getConnection);

            cmd.Parameters.Add("@num", SqlDbType.VarChar).Value = num;

            cmd.Parameters.Add("@vitri", SqlDbType.VarChar).Value = vitri;
            mydb.openConnection();
            if (cmd.ExecuteNonQuery() == 1)
            {
                mydb.closeConnection();
                return(true);
            }
            else
            {
                mydb.closeConnection();
                return(false);
            }
        }