Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["trang"] != null)
            {
                trang = Request.QueryString["trang"].ToString();
            }
            if (string.IsNullOrEmpty(trang))
            {
                trang = "1";
            }

            if (Request.QueryString["s"] != null)
            {
                keyword = Request.QueryString["s"].ToString();
            }

            txtTimKiem.Text = keyword;


            int.TryParse(trang, out pageIndex);
            StartIndex = pageSize * (pageIndex - 1);

            Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
            List <Sys_ThongSoHeThong>    data       = repository.GetTable().Where(x => string.IsNullOrEmpty(keyword) || x.ThongSo.Contains(keyword)).OrderByDescending(x => x.NgayThayDoi).ToList();

            CollectionPager1.MaxPages      = 10000;
            CollectionPager1.PageSize      = 10; // số items hiển thị trên một trang.
            CollectionPager1.DataSource    = data;
            CollectionPager1.BindToControl = rptData;
            rptData.DataSource             = CollectionPager1.DataSourcePaged;
            rptData.DataBind();
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            id    = Request.QueryString["id"] ?? string.Empty;
            trang = Request.QueryString["trang"] ?? string.Empty;
            lblMessage.Visible = false;

            if (!string.IsNullOrEmpty(id))
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));
                txtTen.Text   = entity.ThongSo;
                txtNote.Text  = entity.MoTa;
                txtValue.Text = entity.GiaTri;

                ConfigName = entity.ThongSo;
            }
        }
Example #3
0
        public static string DeleteConfigItem(string itemID)
        {
            AjaxResponse response = new AjaxResponse();

            try
            {
                //Initial data context variable, this class is declared in .dbml file in xRPDAL namespace
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(itemID));
                repository.DeleteOnSubmit(entity);
                repository.SubmitChanges();
                response.IsSuccess = true;
                response.Message   = "OK";
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = (ex.Message + ex.StackTrace).EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }
Example #4
0
        protected void BindData(int id)
        {
            xRPDataContext dts             = new xRPDataContext();
            var            sysconfig       = dts.Sys_ThongSoHeThongs;
            string         tenCongTy       = (from t in sysconfig where t.ThongSo == "TenCongTy" select t.GiaTri).FirstOrDefault();
            string         diaChiCongTy    = (from t in sysconfig where t.ThongSo == "DiaChiCongTy" select t.GiaTri).FirstOrDefault();
            string         dienThoaiCongTy = (from t in sysconfig where t.ThongSo == "DienThoaiLienHe" select t.GiaTri).FirstOrDefault();

            lblTenCongTy.Text       = tenCongTy;
            lblDiaChiCongTy.Text    = "Địa chỉ: " + diaChiCongTy;
            lblDienThoaiCongTy.Text = "Số ĐT: " + dienThoaiCongTy;
            string ngayhomnay = new Sys_ThongSoHeThongRepository().GetThongSoHeThong("DiaPhuong", "Hà Nội") + ", ngày" + " " + DateTime.Now.Day.ToString() + " " + "tháng" + " " + DateTime.Now.Month.ToString() + " " + "năm" + " " + DateTime.Now.Year.ToString();

            lblNgayIn.Text               = ngayhomnay;
            this.currentPhieuNhap        = dts.Qlvt_PhieuNhaps.Where(x => x.ID == id).FirstOrDefault();
            this.currentKhoVatTu         = dts.Qlvt_KhoVatTus.Where(x => x.ID == currentPhieuNhap.MaKhoVatTu).FirstOrDefault();
            lblMaPhieuNhap.Text          = "Mã phiếu nhập kho: " + currentPhieuNhap.MaHieuPhieuNhap;
            lblNhapTaiKho.Text           = "Kho nhập: " + currentKhoVatTu.TenKhoVatTu;
            lblNgayNhapKho.Text          = "Ngày nhập kho: " + currentPhieuNhap.NgayNhap.Value.ToString("dd/MM/yyyy");
            lblNoiDung.Text              = "Nội dung:" + currentPhieuNhap.GhiChu;
            lblNhaCungCap.Text           = "Nhà cung cấp: " + currentPhieuNhap.Qlvt_NhaCungCap.TenNhaCungCap;
            objectDataSource1.DataSource = dts.sp_Baocao_PhieuNhapVatTu(id);
        }
Example #5
0
        public static string AddOrUpdateConfigItem(string id, string name, string value, string note)
        {
            AjaxResponse response = new AjaxResponse();

            try
            {
                if (string.IsNullOrEmpty(id))
                {
                    Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                    Sys_ThongSoHeThong           entity     = new Sys_ThongSoHeThong();

                    string message     = string.Empty;
                    bool   isExistName = false;

                    isExistName = repository.IsExistThongSo(name);


                    if (isExistName)
                    {
                        response.IsSuccess = false;
                        message            = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                    }

                    if (isExistName)
                    {
                        response.Message = message;
                        return(JsonConvert.SerializeObject(response));
                    }

                    entity.ThongSo      = name;
                    entity.MoTa         = note;
                    entity.GiaTri       = value;
                    entity.NgayThayDoi  = DateTime.Now;
                    entity.NguoiThayDoi = Guid.NewGuid();

                    repository.InsertOnSubmit(entity);
                    repository.SubmitChanges();

                    response.IsSuccess = true;
                }
                else
                {
                    Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                    Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));
                    if (entity == null)
                    {
                        response.IsSuccess = false;
                        response.Message   = "Không tồn tại bản ghi";
                        return(JsonConvert.SerializeObject(response));
                    }


                    ///Check trùng tên trong trường hợp sửa
                    if (entity.ThongSo != name)
                    {
                        string message     = string.Empty;
                        bool   isExistName = repository.IsExistThongSo(name);

                        if (isExistName)
                        {
                            response.IsSuccess = false;
                            message            = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                        }

                        if (isExistName)
                        {
                            response.Message = message;
                            return(JsonConvert.SerializeObject(response));
                        }
                    }

                    entity.ThongSo      = name;
                    entity.MoTa         = note;
                    entity.GiaTri       = value;
                    entity.NgayThayDoi  = DateTime.Now;
                    entity.NguoiThayDoi = Guid.NewGuid();
                    repository.SubmitChanges();

                    response.IsSuccess = true;
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = (ex.Message + ex.StackTrace).EncodeJsString();
            }
            return(JsonConvert.SerializeObject(response));
        }
Example #6
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            bool   isSuccess   = false;
            string message     = string.Empty;
            bool   isExistName = false;

            string name  = txtTen.Text;
            string note  = txtNote.Text;
            string value = txtValue.Text;

            if (string.IsNullOrEmpty(id))
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = new Sys_ThongSoHeThong();


                isExistName = repository.IsExistThongSo(name);

                if (isExistName)
                {
                    message = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                }
                else
                {
                    try
                    {
                        entity.ThongSo      = name;
                        entity.MoTa         = note;
                        entity.GiaTri       = value;
                        entity.NgayThayDoi  = DateTime.Now;
                        entity.NguoiThayDoi = Guid.NewGuid();

                        repository.InsertOnSubmit(entity);
                        repository.SubmitChanges();
                        isSuccess = true;
                    }
                    catch
                    {
                        message = "Lỗi trong quá trình cập nhật";
                    }
                }
            }
            else
            {
                Sys_ThongSoHeThongRepository repository = new Sys_ThongSoHeThongRepository();
                Sys_ThongSoHeThong           entity     = repository.GetById(int.Parse(id));

                ConfigName = entity.ThongSo;
                ///Check trùng tên trong trường hợp sửa
                if (entity.ThongSo != name)
                {
                    isExistName = repository.IsExistThongSo(name);

                    if (isExistName)
                    {
                        message = "Tên đã tồn tại, vui lòng nhập tên khác.\n";
                    }
                }
                if (!isExistName)
                {
                    try
                    {
                        entity.ThongSo      = name;
                        entity.MoTa         = note;
                        entity.GiaTri       = value;
                        entity.NgayThayDoi  = DateTime.Now;
                        entity.NguoiThayDoi = Guid.NewGuid();
                        repository.SubmitChanges();
                        isSuccess = true;
                    }
                    catch (Exception ex)
                    {
                        message = "Lỗi trong quá trình cập nhật";
                    }
                }
            }
            if (isSuccess)
            {
                Response.Redirect("default.aspx?page=config");
            }
            else
            {
                //lblMessage.Visible = true;
                //lblMessage.CssClass = "error";
                //lblMessage.Text = message;

                //string message = "Lỗi trong quá trình cập nhật, lỗi: " + ex.Message;
                String cstext2 = "alert('" + message + "');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", cstext2, true);
            }
        }
Example #7
0
        protected void BindData(string lsKhoId, string lsLoaiVatTuId, string lsVatTuId, string lsNhaCungCapId, DateTime?ngayBatDau, DateTime?ngayKetThuc, bool truloi)
        {
            xRPDataContext dataContext = new xRPDataContext();
            Sys_ThongSoHeThongRepository repThongSoHeThong = new Sys_ThongSoHeThongRepository();
            var    sysconfig       = dataContext.Sys_ThongSoHeThongs;
            string tenCongTy       = (from t in sysconfig where t.ThongSo == "TenCongTy" select t.GiaTri).FirstOrDefault();
            string diaChiCongTy    = (from t in sysconfig where t.ThongSo == "DiaChiCongTy" select t.GiaTri).FirstOrDefault();
            string dienThoaiCongTy = (from t in sysconfig where t.ThongSo == "DienThoaiLienHe" select t.GiaTri).FirstOrDefault();

            lblTenCongTy.Text       = tenCongTy;
            lblDiaChiCongTy.Text    = "Địa chỉ: " + diaChiCongTy;
            lblDienThoaiCongTy.Text = "Số ĐT: " + dienThoaiCongTy;
            lblPrintAt.Text         = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
            lblNgayHomNay.Text      = repThongSoHeThong.GetThongSoHeThong("DiaPhuong", "Hà Nội") + ", ngày" + " " + DateTime.Now.Day.ToString() + " " + "tháng" + " " + DateTime.Now.Month.ToString() + " " + "năm" + " " + DateTime.Now.Year.ToString();
            string ngaybatdau = ngayBatDau != null?ngayBatDau.Value.ToString("dd/MM/yyyy") : "";

            string ngayketthuc = ngayKetThuc != null?ngayKetThuc.Value.ToString("dd/MM/yyyy") : "";

            string tungaydenngay = "";

            if (!string.IsNullOrEmpty(ngaybatdau))
            {
                tungaydenngay += "Từ ngày: " + ngaybatdau;
                if (!string.IsNullOrEmpty(ngayketthuc))
                {
                    tungaydenngay += " đến ngày: " + ngayketthuc;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(ngayketthuc))
                {
                    tungaydenngay += "Tính đến ngày: " + ngayketthuc;
                }
                else
                {
                    tungaydenngay = " ";
                }
            }
            lblTuNgayDenNgay.Text = tungaydenngay;
            if (truloi)
            {
                lblTruLoi.Text = "Số liệu thống kê có trừ lõi";
                objectDataSource1.DataSource = dataContext.Sp_Qlvt_BaoCaoNhapXuatTonTheoVatTu_TruLoi(
                    String.IsNullOrEmpty(lsKhoId) == true ? null : lsKhoId,
                    String.IsNullOrEmpty(lsLoaiVatTuId) == true ? null : lsLoaiVatTuId,
                    String.IsNullOrEmpty(lsVatTuId) == true ? null : lsVatTuId,
                    String.IsNullOrEmpty(lsNhaCungCapId) == true ? null : lsNhaCungCapId,
                    ngayBatDau, ngayKetThuc).ToList();
            }
            else
            {
                lblTruLoi.Text = "Số liệu thống kê không trừ lõi";
                objectDataSource1.DataSource = dataContext.Sp_Qlvt_BaoCaoNhapXuatTonTheoVatTu(
                    String.IsNullOrEmpty(lsKhoId) == true ? null : lsKhoId,
                    String.IsNullOrEmpty(lsLoaiVatTuId) == true ? null : lsLoaiVatTuId,
                    String.IsNullOrEmpty(lsVatTuId) == true ? null : lsVatTuId,
                    String.IsNullOrEmpty(lsNhaCungCapId) == true ? null : lsNhaCungCapId,
                    ngayBatDau, ngayKetThuc).ToList();
            }
        }