Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id    = Request["ID"];
        var khId  = Request["KH_ID"];
        var pdvId = Request["PDV_ID"];

        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                Item = ThuChiDal.SelectByDraff(con, false);
                if (khId != null && khId.Length > 36)
                {
                    khId = khId.Substring(khId.LastIndexOf(',') + 1);
                    var kh = KhachHangDal.SelectById(new Guid(khId), con);
                    Item.P_Ten = kh.Ten;
                    Item.P_ID  = kh.ID;
                }
            }
            else
            {
                Item = ThuChiDal.SelectById(con, new Guid(id));
            }
            var listLoai = DanhMucDal.SelectByLDMMa(con, "NDTC-CHI");
            AddChi.ListLoai = listLoai;
            AddChi.Item     = Item;
        }
    }
Пример #2
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);
        }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id    = Request["ID"];
        var khId  = Request["KH_ID"];
        var pdvId = Request["PDV_ID"];
        var ctvId = Request["CTV_ID"];
        var pgvId = Request["PGV_ID"];
        var pbhId = Request["PBH_ID"];

        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                Item = ThuChiDal.SelectByDraff(con, true);
                if (khId != null && khId.Length >= 36)
                {
                    khId = khId.Substring(khId.LastIndexOf(',') + 1);
                    var kh = KhachHangDal.SelectById(new Guid(khId), con);
                    Item.P_Ten = kh.Ten;
                    Item.P_ID  = kh.ID;
                }


                if (pdvId != null && pdvId.Length >= 36)
                {
                    pdvId = pdvId.Substring(pdvId.LastIndexOf(',') + 1);
                    var pdv = PhieuDichVuDal.SelectById(con, new Guid(pdvId));
                    Item.PDV_ID = pdv.ID;
                    Item.PDV_Ma = pdv.Ma;
                    var kh = KhachHangDal.SelectById(pdv.KH_ID, con);
                    Item.P_Ten = kh.Ten;
                    Item.P_ID  = kh.ID;
                }

                if (ctvId != null && ctvId.Length >= 36)
                {
                    ctvId = ctvId.Substring(ctvId.LastIndexOf(',') + 1);
                    var ctv = ChoThueVayDal.SelectById(con, new Guid(ctvId));
                    Item.CTV_ID = ctv.ID;
                    Item.CTV_Ma = ctv.Ma;
                    var kh = KhachHangDal.SelectById(ctv.KH_ID, con);
                    Item.P_Ten = kh.Ten;
                    Item.P_ID  = kh.ID;
                }

                if (pgvId != null && pgvId.Length >= 36)
                {
                    pgvId = pgvId.Substring(pgvId.LastIndexOf(',') + 1);
                    var pgv = PhieuGiatVayDal.SelectById(con, new Guid(pgvId));
                    Item.PGV_ID = pgv.ID;
                    Item.PGV_Ma = pgv.Ma;
                }
                if (pbhId != null && pbhId.Length >= 36)
                {
                    pbhId = pbhId.Substring(pgvId.LastIndexOf(',') + 1);
                    var pbh = PhieuBaoHongDal.SelectById(con, new Guid(pbhId));
                    Item.PBH_ID = pbh.ID;
                    Item.PBH_Ma = pbh.Ma;
                }
            }
            else
            {
                Item = ThuChiDal.SelectById(con, new Guid(id));
            }
            var logoStr = DanhMucDal.SelectByMa("BAOCAO-HEADER-THUCHI", con).Description;
            InPhieuChi.LogoStr = logoStr;
            var listLoai = DanhMucDal.SelectByLDMMa(con, "NDTC-CHI");
            InPhieuChi.ListLoai = listLoai;
            InPhieuChi.Item     = Item;
        }
    }