Example #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id             = Request["ID"];
        var d              = DateTime.Now;
        var cuoiThangTruoc = new DateTime(d.Year, d.Month, 1).AddDays(-1);
        var dauThangSau    = d.AddMonths(6);

        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                View.Item = new HangHoa();;
            }
            else
            {
                Item      = HangHoaDal.SelectById(new Guid(id));
                View.Item = Item;
            }
            var list = SuKienDal.SelectPhieuDichVuForVay(con, cuoiThangTruoc, dauThangSau, id);
            View.List = list;
            var phieuBaoHongList = PhieuBaoHongDal.SelectTopByHhId(con, 10, id);

            var choThueVayList = ChoThueVayDal.SelectTopByHhId(con, 10, id);

            var phieuGiatVayList = PhieuGiatVayDal.SelectTopByHhId(con, 10, id);

            var phieuXuatNhapSanPhamList = PhieuXuatNhapSanPhamDal.SelectTopByHhId(con, 10, id);

            View.PhieuBaoHongList         = phieuBaoHongList;
            View.ChoThueVayList           = choThueVayList;
            View.PhieuGiatVayList         = phieuGiatVayList;
            View.PhieuXuatNhapSanPhamList = phieuXuatNhapSanPhamList;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var id = Request["ID"];
        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                Item = PhieuBaoHongDal.SelectDraff(con);
                Item.Ma = Item.Ma == 0 ? 1 : Item.Ma + 1;
                Item.ID = Guid.NewGuid();

            }
            else
            {
                Item = PhieuBaoHongDal.SelectById(con, new Guid(id));

            }
            Add.Item = Item; ;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var q    = Request["q"];
        var size = Request["size"];

        if (string.IsNullOrEmpty(size))
        {
            size = "10";
        }
        var duyet    = Request["Duyet"];
        var nhanVien = Request["NhanVien"];
        var url      = string.Format("?q={0}&size={1}&NhanVien={2}&", q, size, nhanVien) + "{1}={0}";

        using (var con = DAL.con())
        {
            var pg =
                PhieuBaoHongDal.pagerDuyet(con, url, false, "PBH_Ma desc", q, Convert.ToInt32(size), null, nhanVien);
            List.List = pg.List;
            paging    = pg.Paging;
        }
    }
Example #4
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;
        }
    }
Example #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged = Security.IsAuthenticated();
        var Id     = Request["Id"];
        var IdNull = string.IsNullOrEmpty(Id);

        var q      = Request["q"];
        var refUrl = Request["refUrl"];

        if (!string.IsNullOrEmpty(refUrl))
        {
            refUrl = Server.UrlDecode(refUrl);
        }

        var Ma          = Request["Ma"];
        var HH_ID       = Request["HH_ID"];
        var NgayBaoHong = Request["NgayBaoHong"];
        var LYDO_ID     = Request["LYDO_ID"];
        var MoTa        = Request["MoTa"];
        var NhanVien    = Request["NhanVien"];
        var Duyet       = Request["Duyet"];
        var NguoiDuyet  = Request["NguoiDuyet"];
        var Tien        = Request["Tien"];
        var NgayDuyet   = Request["NgayDuyet"];

        Duyet = string.IsNullOrEmpty(Duyet) ? "false" : "true";
        switch (subAct)
        {
        case "save":
            #region Thêm khách hàng
            if (logged)
            {
                var item = PhieuBaoHongDal.SelectById(DAL.con(), new Guid(Id));
                IdNull = item.ID == Guid.Empty;
                if (!string.IsNullOrEmpty(NguoiDuyet))
                {
                    item.NguoiDuyet = Convert.ToInt32(NguoiDuyet);
                }
                if (!string.IsNullOrEmpty(NhanVien))
                {
                    item.NhanVien = Convert.ToInt32(NhanVien);
                }
                if (!string.IsNullOrEmpty(LYDO_ID))
                {
                    item.LYDO_ID = new Guid(LYDO_ID);
                }
                if (!string.IsNullOrEmpty(HH_ID))
                {
                    item.HH_ID = new Guid(HH_ID);
                }
                if (!string.IsNullOrEmpty(Tien))
                {
                    item.Tien = Convert.ToDouble(Tien);
                }
                item.MoTa = MoTa;

                if (!string.IsNullOrEmpty(Ma))
                {
                    item.Ma = Convert.ToInt32(Ma);
                }

                if (Convert.ToBoolean(Duyet))
                {
                    if (!item.Duyet)
                    {
                        item.NgayDuyet  = DateTime.Now;
                        item.NguoiDuyet = Convert.ToInt32(Security.UserId);
                        var hh = HangHoaDal.SelectById(item.HH_ID);
                        hh.HongVay      = true;
                        hh.NgayCapNhat  = DateTime.Now;
                        hh.NguoiCapNhat = Security.UserId;
                        HangHoaDal.Update(hh);
                    }
                }


                item.Duyet = Convert.ToBoolean(Duyet);

                if (!string.IsNullOrEmpty(NgayBaoHong))
                {
                    item.NgayBaoHong = Convert.ToDateTime(NgayBaoHong, new CultureInfo("vi-vn"));
                }

                if (IdNull)
                {
                    item.ID       = new Guid(Id);
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.UserId;
                }
                item.NgayCapNhat  = DateTime.Now;
                item.NguoiCapNhat = Security.UserId;

                if (IdNull)
                {
                    item = PhieuBaoHongDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới phiếu báo hỏng: {0}", item.MaStr,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.MaStr
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = PhieuBaoHongDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa phiếu báo hỏng: {0}", item.MaStr,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.MaStr
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "remove":
            #region Xóa phiếu xuất nhập/ phiếu dịch vụ
            if (logged && !IdNull)
            {
                var item = PhieuBaoHongDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    PhieuBaoHongDal.DeleteById(new Guid(Id));
                    TimKiemDal.DeleteByPRowId(DAL.con(), item.ID);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} xóa phiếu báo hỏng: {0}", item.MaStr,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.MaStr
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "search":
            #region search
            var pg = PhieuBaoHongDal.pagerNormal(null, false, "PBH_Ma desc", q, 10);
            rendertext(JavaScriptConvert.SerializeObject(pg.List), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }