Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string NgayBD   = Request.QueryString["ngayBD"];
            string NgayKT   = Request.QueryString["NgayKT"];
            string IDNhaCC  = Request.QueryString["IDNhaCC"];
            string strNhaCC = "Tất cả nhà cung cấp";

            if (Int32.Parse(IDNhaCC) != -1)
            {
                dtNhaCungCap dt = new dtNhaCungCap();
                strNhaCC = dt.LayTenNhaCungCap(IDNhaCC);
            }

            string       strNgay = DateTime.Parse(NgayBD).ToString("dd-MM-yyyy") + " - " + DateTime.Parse(NgayKT).ToString("dd-MM-yyyy");
            rpBKNhapHang rp      = new rpBKNhapHang();

            rp.Parameters["IDNhaCC"].Value    = IDNhaCC;
            rp.Parameters["IDNhaCC"].Visible  = false;
            rp.Parameters["strNhaCC"].Value   = strNhaCC;
            rp.Parameters["strNhaCC"].Visible = false;
            rp.Parameters["strNgay"].Value    = strNgay;
            rp.Parameters["strNgay"].Visible  = false;
            rp.Parameters["NgayBD"].Value     = NgayBD;
            rp.Parameters["NgayBD"].Visible   = false;
            rp.Parameters["NgayKT"].Value     = NgayKT;
            rp.Parameters["NgayKT"].Visible   = false;
            viewerReport.Report = rp;
        }
Example #2
0
 public void MaPhieu()
 {
     data = new dtNhaCungCap();
     txtMaPhieu.DataSource = data.DanhSachSoDonHang(cmbNhaCungCap.Value.ToString());
     txtMaPhieu.TextField  = "SoDonHang";
     txtMaPhieu.ValueField = "ID";
     txtMaPhieu.DataBind();
 }
        protected void gridNhaCungCap_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID = e.Keys[0].ToString();

            data = new dtNhaCungCap();
            data.XoaNhaCungCap(Int32.Parse(ID));
            e.Cancel = true;
            gridNhaCungCap.CancelEdit();
            LoadGrid();
        }
        protected void gridNhaCungCap_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            string ID = e.Keys[0].ToString();

            data = new dtNhaCungCap();
            data.XoaNhaCungCap(Int32.Parse(ID));
            e.Cancel = true;
            gridNhaCungCap.CancelEdit();
            LoadGrid();
            dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Nhà Cung Cấp:" + ID, Session["IDKho"].ToString(), "Danh Mục", "Xóa");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         dtNhaCungCap dt = new dtNhaCungCap();
         DataTable    da = dt.LayDanhSach_BaoCao();
         da.Rows.Add(-1, "Tất cả");
         cmbNhaCungCap.DataSource = da;
         cmbNhaCungCap.TextField  = "TenNhaCungCap";
         cmbNhaCungCap.ValueField = "ID";
         cmbNhaCungCap.DataBind();
         cmbNhaCungCap.SelectedIndex = da.Rows.Count;
     }
 }
        protected void gridNhaCungCap_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dtNhaCungCap();
            string tenNhaCungCap    = e.NewValues["TenNhaCungCap"].ToString();
            string dienThoai        = e.NewValues["DienThoai"] == null ? "" : e.NewValues["DienThoai"].ToString();
            string fax              = e.NewValues["Fax"] == null ? "" : e.NewValues["Fax"].ToString();
            string email            = e.NewValues["Email"] == null ? "" : e.NewValues["Email"].ToString();
            string diaChi           = e.NewValues["DiaChi"] == null ? "" : e.NewValues["DiaChi"].ToString();
            string nguoiLienHe      = e.NewValues["NguoiLienHe"] == null ? "" : e.NewValues["NguoiLienHe"].ToString();
            string maSoThue         = e.NewValues["MaSoThue"] == null ? "" : e.NewValues["MaSoThue"].ToString();
            string linhVucKinhDoanh = e.NewValues["LinhVucKinhDoanh"] == null ? "" : e.NewValues["LinhVucKinhDoanh"].ToString();
            //string loGo = ""; //e.NewValues["TenNganhHang"].ToString();
            DateTime NgayCapNhat = DateTime.Today.Date;
            string   ghiChu      = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString();

            data.ThemNhaCungCap(tenNhaCungCap, dienThoai, fax, email, diaChi, nguoiLienHe, maSoThue, linhVucKinhDoanh, NgayCapNhat, ghiChu);
            e.Cancel = true;
            gridNhaCungCap.CancelEdit();
            LoadGrid();
        }
        protected void gridNhaCungCap_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            data = new dtNhaCungCap();
            string   tenNhaCungCap    = e.NewValues["TenNhaCungCap"].ToString();
            string   dienThoai        = e.NewValues["DienThoai"] == null ? "" : e.NewValues["DienThoai"].ToString();
            string   fax              = e.NewValues["Fax"] == null ? "" : e.NewValues["Fax"].ToString();
            string   email            = e.NewValues["Email"] == null ? "" : e.NewValues["Email"].ToString();
            string   diaChi           = e.NewValues["DiaChi"] == null ? "" : e.NewValues["DiaChi"].ToString();
            string   nguoiLienHe      = e.NewValues["NguoiLienHe"] == null ? "" : e.NewValues["NguoiLienHe"].ToString();
            string   maSoThue         = e.NewValues["MaSoThue"] == null ? "" : e.NewValues["MaSoThue"].ToString();
            string   linhVucKinhDoanh = e.NewValues["LinhVucKinhDoanh"] == null ? "" : e.NewValues["LinhVucKinhDoanh"].ToString();
            string   MaNCC            = e.NewValues["MaNCC"].ToString();
            DateTime NgayCapNhat      = DateTime.Today.Date;
            string   ghiChu           = e.NewValues["GhiChu"] == null ? "" : e.NewValues["GhiChu"].ToString();

            //if (dtSetting.kiemTraChuyenDoiDau() == 1)
            //    tenNhaCungCap = dtSetting.convertDauSangKhongDau(tenNhaCungCap).ToUpper();
            if (dtSetting.IsNumber(MaNCC) == true)
            {
                if (dtNhaCungCap.KiemTraMaNCC(MaNCC) == false)
                {
                    data.ThemNhaCungCap(MaNCC, tenNhaCungCap, dienThoai, fax, email, diaChi, nguoiLienHe, maSoThue, linhVucKinhDoanh, NgayCapNhat, ghiChu);
                    e.Cancel = true;
                    gridNhaCungCap.CancelEdit();
                    LoadGrid();
                    dtLichSuTruyCap.ThemLichSu(Session["IDNhanVien"].ToString(), Session["IDNhom"].ToString(), "Nhà Cung Cấp:" + tenNhaCungCap, Session["IDKho"].ToString(), "Danh Mục", "Thêm");
                }
                else
                {
                    throw new Exception("Lỗi: Mã nhà cung cấp đã tồn tại");
                }
            }
            else
            {
                throw new Exception("Lỗi: Mã nhà cung cấp phải là số");
            }
        }
Example #8
0
 private void LoadGrid()
 {
     data = new dtNhaCungCap();
     gridNhaCungCap.DataSource = data.LayDanhSachNhaCungCap();
     gridNhaCungCap.DataBind();
 }
Example #9
0
        protected void btnCapNhatThanhToan_Click(object sender, EventArgs e)
        {
            dtCongNo dt = new dtCongNo();

            if (cmbNhaCungCap.Text != "" && cmbHinhThucThanhToan.Text != "" && txtTienThanhToan.Text != "")
            {
                int    KT                = Int32.Parse(cmbHinhThucThanhToan.Value.ToString());
                string IDNhaCungCap      = cmbNhaCungCap.Value.ToString();
                string HinhThucThanhToan = cmbHinhThucThanhToan.Text.ToString();
                string SoHoaDon          = txtNhapSoHoaDon.Text == null ? "" : txtNhapSoHoaDon.Text;

                float    SoTienThanhToan = float.Parse(txtTienThanhToan.Text);
                string   NoiDung         = txtNoiDung.Text == null ? "" : txtNoiDung.Text;
                DateTime NgayThanhToan   = DateTime.Parse(dateNgayThanhToan.Text);

                if (KT == 0)
                {
                    object ID = dt.ThemChiTietCongNo(SoHoaDon, IDNhaCungCap, HinhThucThanhToan, "", SoTienThanhToan, NoiDung, NgayThanhToan);
                    if (ID != null)
                    {
                        dt.CapNhatCongNo(IDNhaCungCap, SoTienThanhToan);
                        data = new dtNhaCungCap();
                        DataTable db = data.DanhSachSoDonHang(cmbNhaCungCap.Value.ToString());
                        if (db.Rows.Count != 0)
                        {
                            foreach (DataRow dr in db.Rows)
                            {
                                float  TienMaPhieu = float.Parse(dr["TongTien"].ToString());
                                string IDDonHang   = dr["ID"].ToString();
                                if (SoTienThanhToan > TienMaPhieu)
                                {
                                    dt = new dtCongNo();
                                    dt.CapNhatTinhTrang(IDDonHang);
                                    SoTienThanhToan = SoTienThanhToan - TienMaPhieu;
                                }
                                else if (SoTienThanhToan > 0)
                                {
                                    dt = new dtCongNo();
                                    dt.CapNhatTinhTrang(IDDonHang);
                                    SoTienThanhToan = 0;
                                    Response.Redirect("CapNhatCongNo.aspx");
                                }
                            }
                        }
                    }
                }
                if (KT == 1)
                {
                    string IDMaPhieu = txtMaPhieu.Value.ToString();
                    object ID        = dt.ThemChiTietCongNo(SoHoaDon, IDNhaCungCap, HinhThucThanhToan, IDMaPhieu, SoTienThanhToan, NoiDung, NgayThanhToan);
                    if (ID != null)
                    {
                        dt.CapNhatCongNo(IDNhaCungCap, SoTienThanhToan);
                        dt.CapNhatTinhTrang(IDMaPhieu);
                        Response.Redirect("CapNhatCongNo.aspx");
                    }
                }
            }
            else
            {
                Response.Write("<script language='JavaScript'> alert('Vui lòng nhập đủ thông tin.'); </script>");
            }
        }