Exemplo n.º 1
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                int        ID            = int.Parse(txtID.Text);
                Multimedia obj           = db.Multimedia.FirstOrDefault(x => x.ID == ID);
                obj.ID        = Convert.ToInt32(txtID.Text);
                obj.Alt       = txtAlt.Text;
                obj.MaHangHoa = cmbMaHangHoa.SelectedValue;

                db.SaveChanges();
                //Upload file về sever
                string filename = "";
                if (fuAnhHH.HasFile)
                {
                    string ext = Path.GetFileName(fuAnhHH.FileName);
                    ext = ext.Split('.')[ext.Split('.').Length - 1];
                    // Tự sinh tên file đảm bảo tính duy nhất => Dùng thời gian upload file để sinh tên file
                    filename = DateTime.Now.ToString("yyyyMMddhhmmssffff") + "." + ext;
                    fuAnhHH.SaveAs(Server.MapPath("~/UpLoads/") + filename);
                    Multimedia newobj = new Multimedia();
                    newobj.MaHangHoa = obj.MaHangHoa;
                    newobj.Url       = filename;
                    db.Multimedia.Add(newobj);
                    db.SaveChanges();
                }
                Response.Redirect("QLAnhHH.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 2
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                CTHoaDonBan obj = new CTHoaDonBan();
                obj.MaCTHDBan   = txtMaCTHDBan.Text;
                obj.MaHangHoa   = cmbMaHangHoa.SelectedValue;
                obj.SoLuong     = Convert.ToInt32(txtSoLuong.Text);
                obj.DonGia      = Convert.ToInt32(txtDonGia.Text);
                obj.MaCTKM      = cmbMaCTKM.SelectedValue;
                obj.MaHoaDonBan = cmbMaHoaDonBan.SelectedValue;
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.CTHoaDonBan.Add(obj);
                db.SaveChanges();


                Response.Redirect("QLChiTietHDB.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 3
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                CauHinh obj = new CauHinh();
                obj.ID           = txtMaCauHinh.Text;
                obj.TenCongTy    = txtTenCongTy.Text;
                obj.DiaChiCongTy = txtDiaChiCongTy.Text;
                obj.SoDienThoai  = txtSoDienThoai.Text;
                obj.MaSoThue     = txtMaSoThue.Text;
                obj.VAT          = Convert.ToInt32(txtVAT.Text);
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.CauHinh.Add(obj);
                db.SaveChanges();


                Response.Redirect("QLCauHinh.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 4
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                KhachHang obj = new KhachHang();
                obj.MaKhachHang  = txtMaKhachHang.Text;
                obj.TenKhachHang = txtTenKhachHang.Text;
                obj.SoDienThoai  = txtSoDienThoai.Text;
                obj.Gmail        = txtGmail.Text;
                obj.GioiTinh     = txtGioiTinh.Text;
                obj.MatKhau      = txtMatKhau.Text;
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.KhachHang.Add(obj);
                db.SaveChanges();


                Response.Redirect("TrangChu.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 5
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                HangHoa obj = new HangHoa();
                obj.MaHangHoa  = txtMaHangHoa.Text;
                obj.TenHangHoa = txtTenHangHoa.Text;
                obj.SoLuongTon = Convert.ToInt32(txtSoLuongTon.Text);
                obj.DonGia     = Convert.ToInt32(txtDonGia.Text);
                obj.DonViTinh  = txtDonViTinh.Text;
                obj.MaLoai     = Convert.ToInt32(cmbMaLoai.SelectedValue);
                obj.MoTa       = txtMoTa.Text;
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.HangHoa.Add(obj);
                db.SaveChanges();
                //Upload file về sever
                string filename = "";
                if (fuAnhHH.HasFile)
                {
                    string ext = Path.GetFileName(fuAnhHH.FileName);
                    ext = ext.Split('.')[ext.Split('.').Length - 1];
                    // Tự sinh tên file đảm bảo tính duy nhất => Dùng thời gian upload file để sinh tên file
                    filename = DateTime.Now.ToString("yyyyMMddhhmmssffff") + "." + ext;
                    fuAnhHH.SaveAs(Server.MapPath("~/UpLoads/") + filename);
                    Multimedia newobj = new Multimedia();
                    newobj.MaHangHoa = obj.MaHangHoa;
                    newobj.Alt       = obj.TenHangHoa;
                    newobj.Url       = filename;
                    db.Multimedia.Add(newobj);
                    db.SaveChanges();
                }

                Response.Redirect("QLHangHoa.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 6
0
        protected void btnXoa_Command(object sender, CommandEventArgs e)
        {
            //code de xoa du lieu voi ma lop nien che luu trong commandArgument
            string MaCTKM = e.CommandArgument.ToString();
            //xoa du lieu trong database
            //tao doi tuong truy van
            QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
            CTKM data = db.CTKM.FirstOrDefault(x => x.MaCTKM == MaCTKM);

            if (data != null)
            {
                db.CTKM.Remove(data);
                db.SaveChanges();
                getData();
            }
        }
Exemplo n.º 7
0
        protected void btnXoa_Command(object sender, CommandEventArgs e)
        {
            //code de xoa du lieu voi ma lop nien che luu trong commandArgument

            int ID = Convert.ToInt32(e.CommandArgument.ToString());
            //xoa du lieu trong database
            //tao doi tuong truy van
            QLBH_D12TMDTEntities1 db   = new QLBH_D12TMDTEntities1();
            Multimedia            data = db.Multimedia.FirstOrDefault(x => x.ID == ID);

            if (data != null)
            {
                db.Multimedia.Remove(data);
                db.SaveChanges();
                getData();
            }
        }
Exemplo n.º 8
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string MaCTKM            = txtMaCTKM.Text;
                CTKM   obj = db.CTKM.FirstOrDefault(x => x.MaCTKM == MaCTKM);
                obj.MaCTKM   = txtMaCTKM.Text;
                obj.TenCTKM  = txtTenCTKM.Text;
                obj.GiaTriKM = Convert.ToInt32(txtGiaTriKM.Text);
                obj.LoaiKM   = Convert.ToInt32(txtLoaiKM.Text);

                db.SaveChanges();
                Response.Redirect("QLCTKM.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 9
0
 protected void btnThemMoi_Click(object sender, EventArgs e)
 {
     try
     {
         //Trường hợp thêm mới
         CTKM obj = new CTKM();
         obj.MaCTKM   = txtMaCTKM.Text;
         obj.TenCTKM  = txtTenCTKM.Text;
         obj.GiaTriKM = Convert.ToInt32(txtGiaTriKM.Text);
         obj.LoaiKM   = Convert.ToInt32(txtLoaiKM.Text);
         QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
         db.CTKM.Add(obj);
         db.SaveChanges();
         Response.Redirect("QLCTKM.aspx");
     }
     catch
     {
         pnError.Visible = true;
     }
 }
Exemplo n.º 10
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string   MaNhanVien      = txtMaNhanVien.Text;
                NhanVien obj             = db.NhanVien.FirstOrDefault(x => x.MaNhanVien == MaNhanVien);
                obj.MaNhanVien  = txtMaNhanVien.Text;
                obj.TenNhanVien = txtTenNhanVien.Text;
                obj.MatKhau     = txtMatKhau.Text;
                obj.SoDienThoai = txtSoDienThoai.Text;

                db.SaveChanges();
                Response.Redirect("QLNhanVien.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 11
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string     MaHoaDonNhap  = txtMaHoaDonNhap.Text;
                HoaDonNhap obj           = db.HoaDonNhap.FirstOrDefault(x => x.MaHoaDonNhap == MaHoaDonNhap);
                obj.MaHoaDonNhap = txtMaHoaDonNhap.Text;
                obj.NgayNhap     = Convert.ToDateTime(txtNgayNhap.Text);
                obj.MaNhanVien   = cmbMaNhanVien.SelectedValue;
                obj.TongGiaTri   = Convert.ToInt32(txtTongGiaTri.Text);
                obj.MaNguonHang  = cmbMaNguonHang.SelectedValue;
                db.SaveChanges();

                Response.Redirect("QLPhieuNhap.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 12
0
 protected void btnThemMoi_Click(object sender, EventArgs e)
 {
     try
     {
         //Trường hợp thêm mới
         NhanVien obj = new NhanVien();
         obj.MaNhanVien  = txtMaNhanVien.Text;
         obj.TenNhanVien = txtTenNhanVien.Text;
         obj.MatKhau     = txtMatKhau.Text;
         obj.SoDienThoai = txtSoDienThoai.Text;
         //lưu dữ liệu vào db
         QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
         db.NhanVien.Add(obj);
         db.SaveChanges();
         Response.Redirect("QLNhanVien.aspx");
     }
     catch
     {
         pnError.Visible = true;
     }
 }
Exemplo n.º 13
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string       MaCTHDNhap  = txtMaCTHDNhap.Text;
                CTHoaDonNhap obj         = db.CTHoaDonNhap.FirstOrDefault(x => x.MaCTHDNhap == MaCTHDNhap);
                obj.MaCTHDNhap   = txtMaCTHDNhap.Text;
                obj.MaHangHoa    = cmbMaHangHoa.SelectedValue;
                obj.SoLuong      = Convert.ToInt32(txtSoLuong.Text);
                obj.DonGiaNhap   = Convert.ToInt32(txtDonGiaNhap.Text);
                obj.MaHoaDonNhap = cmbMaHoaDonNhap.SelectedValue;
                db.SaveChanges();

                Response.Redirect("QLCTPhieuNhap.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 14
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string    MaHoaDonBan    = txtMaHoaDonBan.Text;
                HoaDonBan obj            = db.HoaDonBan.FirstOrDefault(x => x.MaHoaDonBan == MaHoaDonBan);
                obj.MaHoaDonBan = txtMaHoaDonBan.Text;
                obj.MaNhanVien  = cmbMaNhanVien.SelectedValue;
                obj.MaKhachHang = cmbMaKhachHang.SelectedValue;
                obj.NgayBan     = Convert.ToDateTime(txtNgayBan.Text);
                obj.MaCTKM      = cmbMaCTKM.SelectedValue;

                db.SaveChanges();

                Response.Redirect("QLHoaDonBan.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 15
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string  ID  = txtMaCauHinh.Text;
                CauHinh obj = db.CauHinh.FirstOrDefault(x => x.ID == ID);
                obj.ID           = txtMaCauHinh.Text;
                obj.TenCongTy    = txtTenCongTy.Text;
                obj.DiaChiCongTy = txtDiaChiCongTy.Text;
                obj.SoDienThoai  = txtSoDienThoai.Text;
                obj.MaSoThue     = txtMaSoThue.Text;
                obj.VAT          = Convert.ToInt32(txtVAT.Text);

                db.SaveChanges();

                Response.Redirect("QLCauHinh.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 16
0
        protected void btnLuu_Click(object sender, EventArgs e)
        {
            try
            {
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                string    MaKhachHang    = txtMaKhachHang.Text;
                KhachHang obj            = db.KhachHang.FirstOrDefault(x => x.MaKhachHang == MaKhachHang);
                obj.MaKhachHang  = txtMaKhachHang.Text;
                obj.TenKhachHang = txtTenKhachHang.Text;
                obj.SoDienThoai  = txtSoDienThoai.Text;
                obj.Gmail        = txtGmail.Text;
                obj.GioiTinh     = txtGioiTinh.Text;
                obj.LoaiKH       = Convert.ToInt32(txtLoaiKH.Text);
                obj.MatKhau      = txtMatKhau.Text;

                db.SaveChanges();

                Response.Redirect("QLKhachHang.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 17
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                HoaDonNhap obj = new HoaDonNhap();
                obj.MaHoaDonNhap = txtMaHoaDonNhap.Text;
                obj.NgayNhap     = Convert.ToDateTime(txtNgayNhap.Text);
                obj.MaNhanVien   = cmbMaNhanVien.SelectedValue;
                obj.TongGiaTri   = Convert.ToInt32(txtTongGiaTri.Text);
                obj.MaNguonHang  = cmbMaNguonHang.SelectedValue;
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.HoaDonNhap.Add(obj);
                db.SaveChanges();


                Response.Redirect("QLPhieuNhap.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }
Exemplo n.º 18
0
        protected void btnThemMoi_Click(object sender, EventArgs e)
        {
            try
            {
                //Trường hợp thêm mới
                HoaDonBan obj = new HoaDonBan();
                obj.MaHoaDonBan = txtMaHoaDonBan.Text;
                obj.MaNhanVien  = cmbMaNhanVien.SelectedValue;
                obj.MaKhachHang = cmbMaKhachHang.SelectedValue;
                obj.NgayBan     = Convert.ToDateTime(txtNgayBan.Text);
                obj.MaCTKM      = cmbMaCTKM.SelectedValue;
                //lưu dữ liệu vào db
                QLBH_D12TMDTEntities1 db = new QLBH_D12TMDTEntities1();
                db.HoaDonBan.Add(obj);
                db.SaveChanges();


                Response.Redirect("QLHoaDonBan.aspx");
            }
            catch
            {
                pnError.Visible = true;
            }
        }