Пример #1
0
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var cs = this.Page.ClientScript;

            #region Tham số

            HttpContext     c                   = HttpContext.Current;
            var             ID                  = c.Request["ID"];
            var             NDTC_ID             = c.Request["NDTC_ID"];
            var             SoPhieu             = c.Request["SoPhieu"];
            var             SoTien              = c.Request["SoTien"];
            var             Mota                = c.Request["Mota"];
            var             NgayTao             = c.Request["NgayTao"];
            var             NguoiTao            = c.Request["NguoiTao"];
            var             NgaySua             = c.Request["NgaySua"];
            var             NguoiSua            = c.Request["NguoiSua"];
            var             LoaiQuy             = c.Request["LoaiQuy"];
            var             LoaiCandoi          = c.Request["LoaiCandoi"];
            var             isCandoi            = c.Request["isCandoi"];
            var             Thu                 = c.Request["Thu"];
            var             XN_ID               = c.Request["XN_ID"];
            var             P_ID                = c.Request["P_ID"];
            var             DV_ID               = c.Request["DV_ID"];
            var             TuNgay              = c.Request["TuNgay"];
            var             DenNgay             = c.Request["DenNgay"];
            var             _q                  = c.Request["q"];
            List <jgridRow> ListRow             = new List <jgridRow>();
            var             danhMucKyHieu       = DanhMucDal.SelectByMa("TC-THU");
            var             danhMucReportHeader = DanhMucDal.SelectByMa("BAOCAO-HEADER-THUCHI");
            var             danhMucReportFooter = DanhMucDal.SelectByMa("BAOCAO-FOOTER-THUCHI");
            var             draff               = Request["draff"];
            var             isThu               = true;
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid

                var pagerGet = ThuChiDal.pagerTuNgayDenNgay(jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows),
                                                            isThu, TuNgay, DenNgay, NDTC_ID, null, true);
                string prefixMas = danhMucKyHieu.KyHieu;
                foreach (var item in pagerGet.List)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.NDTC_Ten
                        , prefixMas + item.SoPhieu
                        , item.P_Ten
                        , item.Mota
                        , item.NgayTao.ToString("dd-MM-yyyy")
                        , Lib.TienVietNam(item.SoTien)
                        , item.NguoiTao_Ten
                        , (item.NguoiTao == Security.Username).ToString()
                        , (item.XN_ID != Guid.Empty).ToString()
                        , (item.DV_ID != Guid.Empty).ToString()
                    }));
                }
                jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                            , pagerGet.TotalPages.ToString()
                                            , pagerGet.Total.ToString()
                                            , ListRow);
                sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                break;

                #endregion
            case "del":
                #region xóa
                if (!string.IsNullOrEmpty(ID))
                {
                    ThuChiDal.DeleteById(new Guid(ID));
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(ID))
                {
                    var    item     = ThuChiDal.SelectById(new Guid(ID));
                    string prefixMa = danhMucKyHieu.KyHieu;
                    item.SoPhieu = prefixMa + item.SoPhieu;
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item));
                }
                break;

                #endregion
            case "draff":
                #region draff
                if (Security.IsAuthenticated())
                {
                    var    item     = ThuChiDal.SelectByDraff(isThu);
                    string prefixMa = danhMucKyHieu.KyHieu;
                    item.SoPhieu = prefixMa + item.SoPhieu;
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item));
                }
                break;

                #endregion
            case "save":
                #region save
                if (Security.IsAuthenticated())
                {
                    var item     = draff == "1" ? new ThuChi() : ThuChiDal.SelectById(new Guid(ID));
                    var prefixMa = danhMucKyHieu.KyHieu;
                    SoPhieu      = SoPhieu.Replace(prefixMa, "");
                    item.SoPhieu = SoPhieu;
                    if (!string.IsNullOrEmpty(DV_ID))
                    {
                        item.DV_ID = new Guid(DV_ID);
                    }
                    item.LoaiCandoi = Convert.ToInt32(LoaiCandoi);
                    item.LoaiQuy    = Convert.ToInt32(LoaiQuy);
                    item.Mota       = Mota;
                    if (!string.IsNullOrEmpty(NDTC_ID))
                    {
                        item.NDTC_ID = new Guid(NDTC_ID);
                    }
                    item.NgaySua  = DateTime.Now;
                    item.NguoiSua = Security.Username;
                    if (!string.IsNullOrEmpty(P_ID))
                    {
                        item.P_ID = new Guid(P_ID);
                    }
                    item.SoTien = Convert.ToDouble(SoTien);
                    item.Thu    = isThu;
                    if (!string.IsNullOrEmpty(XN_ID))
                    {
                        item.XN_ID = new Guid(XN_ID);
                    }
                    item.isCandoi = true;
                    item.NgayTao  = Convert.ToDateTime(NgayTao, new CultureInfo("vi-Vn"));

                    if (draff == "1")
                    {
                        item.ID       = new Guid(ID);
                        item.NguoiTao = NguoiTao;
                        item          = ThuChiDal.Insert(item);
                    }
                    else
                    {
                        item = ThuChiDal.Update(item);
                    }
                    // TODO: Tiếp tục phần thu chi
                    sb.Append("1");
                }
                break;

                #endregion
            case "reports":
                #region bao cao
                if (!string.IsNullOrEmpty(ID))
                {
                    var itemIn = Lib.GetResource(Assembly.GetExecutingAssembly(), "quanLyThuDauKy.in-natural.htm");
                    var item   = ThuChiDal.SelectById(new Guid(ID));
                    sb.AppendFormat(itemIn
                                    , string.Format("Ng&agrave;y {4}{0} th&aacute;ng {3}{1} năm {2}", item.NgayTao.Day, item.NgayTao.Month, item.NgayTao.Year, item.NgayTao.Month < 10 ? "0" : "", item.NgayTao.Day < 10 ? "0" : "")
                                    , item.NDTC_Ten
                                    , string.Format("{0}{1}", danhMucKyHieu.KyHieu, item.SoPhieu)
                                    , (item.LoaiQuy == 1 ? "Tài khoản" : "Tiền mặt")
                                    , Lib.TienVietNam(item.SoTien)
                                    , Lib.So_chu(item.SoTien)
                                    , item.P_Ten
                                    , item.NguoiTao_Ten
                                    , item.Mota
                                    , domain
                                    , danhMucReportHeader.Description
                                    , danhMucReportFooter.Description);
                }

                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.JScript1.js"));
                //sb.AppendFormat(@"{0}"
                //    , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.Publish.js"));
                break;

                #endregion
            default:
                #region nạp
                var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "quanLyThuDauKy.mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.quanLyThuDauKy.JScript1.js")
                                , "{quanLyThuDauKyDauKyFn.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
Пример #2
0
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var cs = this.Page.ClientScript;

            #region Tham số

            var _ID = Request["ID"];
            if (string.IsNullOrEmpty(_ID))
            {
                _ID = Guid.Empty.ToString();
            }
            var         No      = Request["No"];
            HttpContext c       = HttpContext.Current;
            var         listRow = new List <jgridRow>();
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid

                foreach (var item in KhachHangDal.SelectCongNo(No))
                {
                    listRow.Add(new jgridRow(item.ID.ToString(), new string[]
                    {
                        item.ID.ToString()
                        , item.Ten
                        , Lib.TienVietNam(item.CongNoDauKy)
                        , Lib.TienVietNam(item.TongNhap)
                        , Lib.TienVietNam(item.TongXuat)
                        , Lib.TienVietNam(item.TongThu)
                        , Lib.TienVietNam(item.TongChi)
                        , Lib.TienVietNam(item.TongDichVu)
                        , Lib.TienVietNam(item.CongNo)
                    }));
                }
                var gridSpAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                          , "1"
                                          , "1000"
                                          , listRow);
                sb.Append(JavaScriptConvert.SerializeObject(gridSpAdm));
                break;

                #endregion
            case "getSubXuat":
                #region getSubXuat
                if (!string.IsNullOrEmpty(_ID))
                {
                    var danhMucLoaiXuatNhap = DanhMucDal.SelectByMa("LXN-X");
                    var pagerGet            = XuatNhapDal.pagerXuatNhap(true.ToString(), false.ToString(), false.ToString(), false.ToString(), _ID,
                                                                        jgrsidx + " " + jgrsord, string.Empty,
                                                                        Convert.ToInt32(jgRows));
                    string prefixMas = danhMucLoaiXuatNhap.KyHieu;
                    foreach (var item in pagerGet.List)
                    {
                        listRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                            item.ID.ToString()
                            , item.LOAI_Ten
                            , prefixMas + item.Ma
                            , item.KH_Ten
                            , item.NgayHoaDon.ToString("dd-MM-yyyy")
                            , Lib.TienVietNam(item.CongTienHang)
                            , Lib.TienVietNam(item.VAT)
                            , Lib.TienVietNam(item.ChietKhau)
                            , Lib.TienVietNam(item.CongTienHang + item.VAT - item.ChietKhau)
                            , Lib.TienVietNam(item.ThanhToan)
                            , Lib.TienVietNam(item.ConNo)
                            , string.Format("{0:dd/MM/yy}", item.NgayCapNhat)
                        }));
                    }
                    jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                                , pagerGet.TotalPages.ToString()
                                                , pagerGet.Total.ToString()
                                                , listRow);
                    sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                }
                break;

                #endregion
            case "getSubNhap":
                #region getSubNhap
                if (!string.IsNullOrEmpty(_ID))
                {
                    var danhMucLoaiXuatNhap = DanhMucDal.SelectByMa("LXN-N");
                    var pagerGet            = XuatNhapDal.pagerXuatNhap(false.ToString(), false.ToString(), false.ToString(), false.ToString(), _ID,
                                                                        jgrsidx + " " + jgrsord, string.Empty,
                                                                        Convert.ToInt32(jgRows));
                    string prefixMas = danhMucLoaiXuatNhap.KyHieu;
                    foreach (var item in pagerGet.List)
                    {
                        listRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                            item.ID.ToString()
                            , item.LOAI_Ten
                            , prefixMas + item.Ma
                            , item.KH_Ten
                            , item.NgayHoaDon.ToString("dd-MM-yyyy")
                            , Lib.TienVietNam(item.CongTienHang)
                            , Lib.TienVietNam(item.VAT)
                            , Lib.TienVietNam(item.ChietKhau)
                            , Lib.TienVietNam(item.CongTienHang + item.VAT - item.ChietKhau)
                            , Lib.TienVietNam(item.ThanhToan)
                            , Lib.TienVietNam(item.ConNo)
                            , string.Format("{0:dd/MM/yy}", item.NgayCapNhat)
                        }));
                    }
                    jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                                , pagerGet.TotalPages.ToString()
                                                , pagerGet.Total.ToString()
                                                , listRow);
                    sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                }
                break;

                #endregion
            case "getSubThu":
                #region getSubThu
                if (!string.IsNullOrEmpty(_ID))
                {
                    var pagerGet = ThuChiDal.pagerTuNgayDenNgay(jgrsidx + " " + jgrsord, null,
                                                                Convert.ToInt32(jgRows),
                                                                true, null, null, null, _ID);
                    var    danhMucKyHieu = DanhMucDal.SelectByMa("TC-THU");
                    string prefixMas     = danhMucKyHieu.KyHieu;
                    foreach (var item in pagerGet.List)
                    {
                        listRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                            item.ID.ToString()
                            , item.NDTC_Ten
                            , prefixMas + item.SoPhieu
                            , item.P_Ten
                            , item.Mota
                            , item.NgayTao.ToString("dd-MM-yyyy")
                            , Lib.TienVietNam(item.SoTien)
                            , item.NguoiTao_Ten
                            , (item.NguoiTao == Security.Username).ToString()
                            , (item.XN_ID != Guid.Empty).ToString()
                            , (item.DV_ID != Guid.Empty).ToString()
                        }));
                    }
                    jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                                , pagerGet.TotalPages.ToString()
                                                , pagerGet.Total.ToString()
                                                , listRow);
                    sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                }

                break;

                #endregion
            case "getSubChi":
                #region lấy dữ liệu cho getSubThu
                if (!string.IsNullOrEmpty(_ID))
                {
                    var pagerGet = ThuChiDal.pagerTuNgayDenNgay(jgrsidx + " " + jgrsord, null,
                                                                Convert.ToInt32(jgRows),
                                                                false, null, null, null, _ID);
                    var    danhMucKyHieu = DanhMucDal.SelectByMa("TC-CHI");
                    string prefixMas     = danhMucKyHieu.KyHieu;
                    foreach (var item in pagerGet.List)
                    {
                        listRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                            item.ID.ToString()
                            , item.NDTC_Ten
                            , prefixMas + item.SoPhieu
                            , item.P_Ten
                            , item.Mota
                            , item.NgayTao.ToString("dd-MM-yyyy")
                            , Lib.TienVietNam(item.SoTien)
                            , item.NguoiTao_Ten
                            , (item.NguoiTao == Security.Username).ToString()
                            , (item.XN_ID != Guid.Empty).ToString()
                            , (item.DV_ID != Guid.Empty).ToString()
                        }));
                    }
                    jgrid gridSPAdm = new jgrid(string.IsNullOrEmpty(jgrpage) ? "1" : jgrpage
                                                , pagerGet.TotalPages.ToString()
                                                , pagerGet.Total.ToString()
                                                , listRow);
                    sb.Append(JavaScriptConvert.SerializeObject(gridSPAdm));
                }

                break;

                #endregion
            case "scpt":
                #region Nạp js
                sb.AppendFormat(@"{0}"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.baoCaoNo.JScript1.js"));
                //sb.AppendFormat(@"{0}"
                //    , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.baoCaoNo.Publish.js"));
                break;

                #endregion
            default:
                #region nạp
                var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "baoCaoNo.mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.thuChiMgr.baoCaoNo.JScript1.js")
                                , "{baoCaoNoFn.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }