示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var q    = Request["q"];
        var size = Request["size"];

        if (string.IsNullOrEmpty(size))
        {
            size = "10";
        }
        var dmId = Request["DM_ID"];
        var gia  = Request["Gia"];

        var url = string.Format("?q={0}&size={1}&DM_ID={2}&Gia={3}", q, size, dmId, gia) + "{1}={0}";

        using (var con = DAL.con())
        {
            var pg =
                HangHoaDal.KhoVay(con, url, false, null, q, Convert.ToInt32(size), dmId, gia);
            List.List = pg.List;
            paging    = pg.Paging;

            var nhomHangHoa = DanhMucDal.SelectByLDMMa(con, "HangHoa");
            DM_ID.List = nhomHangHoa;
        }
    }
示例#2
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;
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var id = Request["ID"];

        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                Add.Item = new HangHoa();;
            }
            else
            {
                Item     = HangHoaDal.SelectById(new Guid(id));
                Add.Item = Item;
            }
        }
    }
    public static DatHangChiTiet getFromReader(IDataReader rd)
    {
        var Item = new DatHangChiTiet();

        if (rd.FieldExists("DHCT_ID"))
        {
            Item.ID = (Guid)(rd["DHCT_ID"]);
        }
        if (rd.FieldExists("DHCT_DH_ID"))
        {
            Item.DH_ID = (Guid)(rd["DHCT_DH_ID"]);
        }
        if (rd.FieldExists("DHCT_HH_ID"))
        {
            Item.HH_ID = (Guid)(rd["DHCT_HH_ID"]);
        }
        if (rd.FieldExists("DHCT_HH_Ten"))
        {
            Item.HH_Ten = (String)(rd["DHCT_HH_Ten"]);
        }
        if (rd.FieldExists("DHCT_HH_SoLuong"))
        {
            Item.HH_SoLuong = (Int32)(rd["DHCT_HH_SoLuong"]);
        }
        if (rd.FieldExists("DHCT_HH_Gia"))
        {
            Item.HH_Gia = (Int32)(rd["DHCT_HH_Gia"]);
        }
        if (rd.FieldExists("DHCT_HH_Tong"))
        {
            Item.HH_Tong = (Int32)(rd["DHCT_HH_Tong"]);
        }
        if (rd.FieldExists("DHCT_NgayTao"))
        {
            Item.NgayTao = (DateTime)(rd["DHCT_NgayTao"]);
        }
        Item._HangHoa = HangHoaDal.getFromReader(rd);
        return(Item);
    }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged = Security.IsAuthenticated();
        var Id     = Request["Id"];
        var IdNull = string.IsNullOrEmpty(Id);

        var Ma    = Request["Ma"];
        var ThuTu = Request["ThuTu"];
        var Ten   = Request["Ten"];
        var MoTa  = Request["MoTa"];
        var GNY   = Request["GNY"];


        var GiaMin = Request["GiaMin"];
        var GiaMax = Request["GiaMax"];
        var refUrl = Request["refUrl"];
        var GDVID  = Request["GDVID"];
        var q      = Request["q"];

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


        switch (subAct)
        {
        case "save":
            #region Thêm khách hàng
            if (logged)
            {
                var item = IdNull ? new GoiDichVu() : GoiDichVuDal.SelectById(new Guid(Id));
                item.Ten         = Ten;
                item.Ma          = Ma;
                item.MoTa        = MoTa;
                item.NgayCapNhat = DateTime.Now;
                if (!string.IsNullOrEmpty(GNY))
                {
                    item.GNY = Convert.ToDouble(GNY);
                }
                if (!string.IsNullOrEmpty(ThuTu))
                {
                    item.ThuTu = Convert.ToInt32(ThuTu);
                }
                if (!string.IsNullOrEmpty(GiaMin))
                {
                    item.GiaMin = Convert.ToDouble(GiaMin);
                }
                if (!string.IsNullOrEmpty(GiaMax))
                {
                    item.GiaMax = Convert.ToDouble(GiaMax);
                }

                if (IdNull)
                {
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.UserId;
                    item.ID       = Guid.NewGuid();
                    item          = GoiDichVuDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} thêm mới gói dịch vụ {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = GoiDichVuDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} sửa gói dịch vụ {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "saveDvCt":
            #region save Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(GDVID) && !string.IsNullOrEmpty(Id))
            {
                var hh  = HangHoaDal.SelectById(new Guid(Id));
                var gdv = GoiDichVuDal.SelectById(new Guid(GDVID));

                var item = new GoiDichVuChiTiet();
                item.ID            = Guid.NewGuid();
                item.HH_ID         = hh.ID;
                item.GDV_ID        = gdv.ID;
                item.Gia           = hh.GNY;
                item.SoLuong       = 1;
                item.Tien          = item.Gia * item.SoLuong;
                item.NgayCapNhat   = DateTime.Now;
                item.NgayTao       = DateTime.Now;
                item.NguoiTao      = Security.UserId;
                item               = GoiDichVuChiTietDal.Insert(item);
                ItemDichVu.Item    = item;
                ItemDichVu.Visible = true;
            }
            break;

            #endregion
        case "updateDvCt":
            #region update Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(Id))
            {
                var SoLuong = Request["SoLuong"];
                var Gia     = Request["Gia"];

                var item = GoiDichVuChiTietDal.SelectById(new Guid(Id));
                if (!string.IsNullOrEmpty(Gia))
                {
                    item.Gia = Convert.ToDouble(Gia);
                }
                if (!string.IsNullOrEmpty(SoLuong))
                {
                    item.SoLuong = Convert.ToInt32(SoLuong);
                }
                if (!string.IsNullOrEmpty(ThuTu))
                {
                    item.ThuTu = Convert.ToInt32(ThuTu);
                }
                item.Tien        = item.Gia * item.SoLuong;
                item.NgayCapNhat = DateTime.Now;
                item             = GoiDichVuChiTietDal.Update(item);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "remove":
            #region Xóa khách hàng
            if (logged && !IdNull)
            {
                var item = GoiDichVuDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    GoiDichVuDal.DeleteById(new Guid(Id));
                    TimKiemDal.DeleteByPRowId(DAL.con(), item.ID);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} xóa gói dịch vụ {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "removeDvCt":
            #region Xóa Goi dich vu chi tiet
            if (logged && !IdNull)
            {
                var item = GoiDichVuChiTietDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    GoiDichVuChiTietDal.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 gói dịch vụ chi tiết {0}", item.HH_Ten,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.HH_Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "search":
            #region search
            var list = GoiDichVuDal.SelectAll();
            rendertext(JavaScriptConvert.SerializeObject(list), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }
示例#6
0
        protected override void Render(HtmlTextWriter writer)
        {
            var sb = new StringBuilder();
            var cs = this.Page.ClientScript;

            #region Tham số
            var             ID           = Request["ID"];
            var             DM_ID        = Request["DM_ID"];
            var             GH_ID        = Request["GH_ID"];
            var             Lang         = Request["Lang"];
            var             LangBased_ID = Request["LangBased_ID"];
            var             LangBased    = Request["LangBased"];
            var             Alias        = Request["Alias"];
            var             Ten          = Request["Ten"];
            var             Ma           = Request["Ma"];
            var             Keywords     = Request["Keywords"];
            var             Description  = Request["Description"];
            var             MoTa         = Request["MoTa"];
            var             NoiDung      = Request["NoiDung"];
            var             GNY          = Request["GNY"];
            var             GiaNhap      = Request["GiaNhap"];
            var             DonVi_ID     = Request["DonVi_ID"];
            var             SoLuong      = Request["SoLuong"];
            var             RowId        = Request["RowId"];
            var             NgayTao      = Request["NgayTao"];
            var             NguoiTao     = Request["NguoiTao"];
            var             NgayCapNhat  = Request["NgayCapNhat"];
            var             NguoiCapNhat = Request["NguoiCapNhat"];
            var             Anh          = Request["Anh"];
            var             Publish      = Request["Publish"];
            var             Active       = Request["Active"];
            var             Home         = Request["Home"];
            var             Hot1         = Request["Hot1"];
            var             Hot2         = Request["Hot2"];
            var             Hot3         = Request["Hot3"];
            var             Hot4         = Request["Hot4"];
            var             HetHang      = Request["HetHang"];
            var             TonDinhMuc   = Request["TonDinhMuc"];
            var             Draff        = Request["Draff"];
            var             _q           = Request["q"];
            var             draff        = Request["draff"];
            var             Loai         = Request["Loai"];
            var             Rep_Ten      = Request["Rep_Ten"];
            var             Rep_Ngay     = Request["Rep_Ngay"];
            var             _F_ID        = Request["F_ID"];
            List <jgridRow> ListRow      = new List <jgridRow>();

            //List<DanhMuc> ListDanhMucBG = new List<DanhMuc>();
            #endregion
            switch (subAct)
            {
            case "get":
                #region lấy dữ liệu cho grid
                var pagerGet = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID);
                foreach (HangHoa item in pagerGet.List)
                {
                    ListRow.Add(new jgridRow(item.ID.ToString(), new string[] {
                        item.ID.ToString()
                        , item.DM_Ten
                        , item.Ma
                        , item.Ten
                        , Lib.TienVietNam(item.GiaNhap)
                        , Lib.TienVietNam(item.GNY)
                        , item.SoLuong.ToString()
                        , item.DonVi_Ten
                        , 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 "del":
                #region xóa
                if (!string.IsNullOrEmpty(ID))
                {
                    HangHoaDal.DeleteByMultiId(ID);
                }
                break;

                #endregion
            case "edit":
                #region chỉnh sửa
                if (!string.IsNullOrEmpty(ID))
                {
                    var hhitem = HangHoaDal.SelectById(new Guid(ID));
                    hhitem.ListFiles = FilesDal.SelectByPRowId(hhitem.ID);
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(hhitem));
                }
                break;

                #endregion
            case "draff":
                #region draff
                sb.Append(Guid.NewGuid().ToString());
                break;

                #endregion
            case "autoCompleteByQ":
                #region lấy dữ liệu cho grid
                var pagerByQ = HangHoaDal.ByDm("", false, "HH_NgayTao asc", _q, 10, string.Empty);
                sb.Append(JavaScriptConvert.SerializeObject(pagerByQ.List));
                break;

                #endregion
            case "save":
                #region save
                if (Security.IsAuthenticated())
                {
                    var item = draff == "1" ? new HangHoa() : HangHoaDal.SelectById(new Guid(ID));
                    item.DM_ID        = new Guid(DM_ID);
                    item.Ten          = Ten;
                    item.Ma           = Ma;
                    item.Keywords     = Keywords;
                    item.MoTa         = MoTa;
                    item.NoiDung      = NoiDung;
                    item.GNY          = Convert.ToDouble(GNY);
                    item.GiaNhap      = Convert.ToDouble(GiaNhap);
                    item.DonVi_ID     = new Guid(DonVi_ID);
                    item.SoLuong      = Convert.ToDouble(SoLuong);
                    item.Anh          = Anh;
                    item.HetHang      = Convert.ToBoolean(HetHang);
                    item.TonDinhMuc   = Convert.ToDouble(TonDinhMuc);
                    item.NguoiCapNhat = Security.Username;
                    item.NgayCapNhat  = DateTime.Now;
                    if (draff == "1")
                    {
                        item.ID       = new Guid(ID);
                        item.NgayTao  = DateTime.Now;
                        item.NguoiTao = Security.Username;
                        item.RowId    = Guid.NewGuid();
                        item          = HangHoaDal.Insert(item);
                    }
                    else
                    {
                        item = HangHoaDal.Update(item);
                    }
                    sb.Append("1");
                }
                break;

                #endregion
            case "DeleteDoc":
                #region Xóa tài liệu đính kèm
                if (!string.IsNullOrEmpty(_F_ID))
                {
                    Files  item   = FilesDal.SelectById(Convert.ToInt32(_F_ID));
                    string _files = Server.MapPath("~/lib/up/sanpham/") + item.ThuMuc + @"\";
                    string _file1 = _files + @"\" + item.Ten + item.MimeType;
                    string _file2 = _files + @"\" + item.Ten + "400x400" + item.MimeType;
                    if (Directory.Exists(_files))
                    {
                        File.Delete(_file1);
                        File.Delete(_file2);
                        Directory.Delete(_files);
                    }
                    FilesDal.DeleteById(item.ID);
                }
                break;

                #endregion
            case "reports":
                #region bao cao
                var pagerGetReport = HangHoaDal.ByDm("", false, jgrsidx + " " + jgrsord, _q, Convert.ToInt32(jgRows), DM_ID);

                break;

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

                #endregion
            default:
                #region nạp
                var listFn = FunctionDal.SelectByUserAndFNID(Security.Username, fnId);
                sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "mdl.htm"));
                sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                                , cs.GetWebResourceUrl(typeof(Class1), "appStore.commonStore.hangHoaMgr.JScript1.js")
                                , "{hangHoaMgrFn.loadgrid();}");
                sb.AppendFormat("<script>adm.validFn('{0}');</script>", JavaScriptConvert.SerializeObject(listFn));
                break;
                #endregion
            }
            writer.Write(sb.ToString());
            base.Render(writer);
        }
示例#7
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;
        }
    }
示例#8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged   = Security.IsAuthenticated();
        var Id       = Request["Id"];
        var PDVDV_Id = Request["PDVDV_Id"];
        var IdNull   = string.IsNullOrEmpty(Id);

        var PDV_ID         = Request["PDV_ID"];
        var GDV_ID         = Request["GDV_ID"];
        var HH_ID          = Request["HH_ID"];
        var ThuTu          = Request["ThuTu"];
        var Ten            = Request["Ten"];
        var MoTa           = Request["MoTa"];
        var Gia            = Request["Gia"];
        var SoLuong        = Request["SoLuong"];
        var Tien           = Request["Tien"];
        var PDVDV_NhanVien = Request["PDVDV_NhanVien"];

        var refUrl = Request["refUrl"];

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

        switch (subAct)
        {
        case "save":
            #region save Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(PDV_ID) && !string.IsNullOrEmpty(HH_ID))
            {
                var hh = HangHoaDal.SelectById(new Guid(HH_ID));

                var item = new PhieuDichVuDichVu();
                item.ID = Guid.NewGuid();

                item.HH_ID       = hh.ID;
                item.PDV_ID      = new Guid(PDV_ID);
                item.MoTa        = string.Empty;
                item.Gia         = hh.GNY;
                item.SoLuong     = 1;
                item.Tien        = item.Gia * item.SoLuong;
                item.NgayCapNhat = DateTime.Now;
                item.NgayTao     = DateTime.Now;
                item.NguoiTao    = Security.UserId;
                item.DichVuThem  = true;
                item             = PhieuDichVuDichVuDal.Insert(item);
                if (!string.IsNullOrEmpty(PDVDV_NhanVien))
                {
                    item.NhanVien = Convert.ToInt32(PDVDV_NhanVien);
                }
                else
                {
                    item.NhanVien = Security.UserId;
                }
                ItemEdit.Item    = item;
                ItemEdit.Visible = true;
            }
            break;

            #endregion
        case "saveByGoiDichVu":
            #region save all goi dich vu
            if (!string.IsNullOrEmpty(PDV_ID) && !string.IsNullOrEmpty(GDV_ID))
            {
                var listDichVu = new List <PhieuDichVuDichVu>();
                using (var con = DAL.con())
                {
                    var listDichVuTheoDoi = GoiDichVuChiTietDal.SelectByGDV(con, GDV_ID);

                    foreach (var itemDv in listDichVuTheoDoi)
                    {
                        var item = new PhieuDichVuDichVu();
                        item.ID = Guid.NewGuid();

                        item.HH_ID       = itemDv.HH_ID;
                        item.PDV_ID      = new Guid(PDV_ID);
                        item.MoTa        = string.Empty;
                        item.Gia         = itemDv.Gia;
                        item.SoLuong     = itemDv.SoLuong;
                        item.Tien        = item.Gia * item.SoLuong;
                        item.NgayCapNhat = DateTime.Now;
                        item.ThuTu       = itemDv.ThuTu;
                        item.NgayTao     = DateTime.Now;
                        item.NguoiTao    = Security.UserId;
                        item.DichVuThem  = false;
                        item.NhanVien    = Security.UserId;
                        item             = PhieuDichVuDichVuDal.Insert(item);
                        listDichVu.Add(item);
                    }
                }
                ListAjaxResult.List    = listDichVu;
                ListAjaxResult.Visible = true;
            }
            break;

            #endregion
        case "update":
            #region update Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(PDVDV_Id))
            {
                var item = PhieuDichVuDichVuDal.SelectById(new Guid(PDVDV_Id));
                if (!string.IsNullOrEmpty(Gia))
                {
                    item.Gia = Convert.ToDouble(Gia);
                }
                if (!string.IsNullOrEmpty(SoLuong))
                {
                    item.SoLuong = Convert.ToInt32(SoLuong);
                }
                if (!string.IsNullOrEmpty(ThuTu))
                {
                    item.ThuTu = Convert.ToInt32(ThuTu);
                }
                if (!string.IsNullOrEmpty(PDVDV_NhanVien))
                {
                    item.NhanVien = Convert.ToInt32(PDVDV_NhanVien);
                }
                item.MoTa        = MoTa;
                item.Tien        = item.Gia * item.SoLuong;
                item.NgayCapNhat = DateTime.Now;
                item             = PhieuDichVuDichVuDal.Update(item);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "remove":
            #region Xóa Goi dich vu chi tiet
            if (logged && !IdNull)
            {
                var item = PhieuDichVuDichVuDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    PhieuDichVuDichVuDal.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 gói dịch vụ trong phiếu dịch vụ {0}", item.PDV_Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.HH_Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        default: break;
        }
    }
示例#9
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged = Security.IsAuthenticated();
        var Id     = Request["Id"];
        var IdNull = string.IsNullOrEmpty(Id);

        var Ma             = Request["Ma"];
        var PDV_ID         = Request["PDV_ID"];
        var PXNSP_ID       = Request["PXNSP_ID"];
        var HH_ID          = Request["HH_ID"];
        var PXNSPCT_ID     = Request["PXNSPCT_ID"];
        var NgayLap        = Request["NgayLap"];
        var TrangThai      = Request["TrangThai"];
        var NgayXuat       = Request["NgayXuat"];
        var NgayNhapDuKien = Request["NgayNhapDuKien"];
        var NguoiXuat      = Request["NguoiXuat"];
        var NgayNhap       = Request["NgayNhap"];
        var NguoiNhap      = Request["NguoiNhap"];
        var ThuKho         = Request["ThuKho"];
        var q      = Request["q"];
        var refUrl = Request["refUrl"];

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

        switch (subAct)
        {
        case "save":
            #region Thêm khách hàng
            if (logged)
            {
                var item = PhieuXuatNhapSanPhamDal.SelectById(DAL.con(), new Guid(Id));
                IdNull = item.ID == Guid.Empty;
                if (!string.IsNullOrEmpty(NguoiXuat))
                {
                    item.NguoiXuat = Convert.ToInt32(NguoiXuat);
                }
                if (!string.IsNullOrEmpty(NguoiNhap))
                {
                    item.NguoiNhap = Convert.ToInt32(NguoiNhap);
                }
                if (!string.IsNullOrEmpty(ThuKho))
                {
                    item.ThuKho = Convert.ToInt32(ThuKho);
                }


                if (!string.IsNullOrEmpty(Ma))
                {
                    item.Ma = Convert.ToInt32(Ma);
                }
                if (!string.IsNullOrEmpty(TrangThai))
                {
                    item.TrangThai = Convert.ToInt32(TrangThai);
                }
                if (!string.IsNullOrEmpty(PDV_ID))
                {
                    item.PDV_ID = new Guid(PDV_ID);
                }


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

                item.NgayCapNhat = DateTime.Now;

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

                if (IdNull)
                {
                    item = PhieuXuatNhapSanPhamDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới phiếu xuất sản phẩm/ phiếu dịch vụ: {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 = PhieuXuatNhapSanPhamDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa phiếu xuất sản phẩm/ phiếu dịch vụ: {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 "saveCt":
            #region save Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(PXNSP_ID) && !string.IsNullOrEmpty(HH_ID))
            {
                var hh = HangHoaDal.SelectById(new Guid(HH_ID));

                var item = new PhieuXuatNhapSanPhamChiTiet();
                item.ID          = Guid.NewGuid();
                item.HH_ID       = hh.ID;
                item.PXNSP_ID    = new Guid(PXNSP_ID);
                item.SoLuong     = 1;
                item.NgayCapNhat = DateTime.Now;
                item.NgayTao     = DateTime.Now;
                item.NguoiTao    = Security.UserId;
                item             = PhieuXuatNhapSanPhamChiTietDal.Insert(item);
                ItemEdit.Item    = item;
                ItemEdit.Visible = true;
            }
            break;

            #endregion
        case "updateCt":
            #region update Goi dich vu chi tiet
            if (!string.IsNullOrEmpty(PXNSPCT_ID))
            {
                var SoLuong = Request["SoLuong"];
                var DaXuat  = Request["DaXuat"];
                var DaNhap  = Request["DaNhap"];
                DaXuat = !string.IsNullOrEmpty(DaXuat) ? "true" : "false";
                DaNhap = !string.IsNullOrEmpty(DaNhap) ? "true" : "false";

                var item = PhieuXuatNhapSanPhamChiTietDal.SelectById(new Guid(PXNSPCT_ID));
                if (!string.IsNullOrEmpty(SoLuong))
                {
                    item.SoLuong = Convert.ToInt32(SoLuong);
                }
                item.DaXuat      = Convert.ToBoolean(DaXuat);
                item.DaNhap      = Convert.ToBoolean(DaNhap);
                item.NgayCapNhat = DateTime.Now;
                item             = PhieuXuatNhapSanPhamChiTietDal.Update(item);
                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 = PhieuXuatNhapSanPhamDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    PhieuXuatNhapSanPhamDal.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 xuất sản phẩm/ phiếu dịch vụ: {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 "removeCt":
            #region Xóa Goi dich vu chi tiet
            if (logged && !string.IsNullOrEmpty(Id))
            {
                var item = PhieuXuatNhapSanPhamChiTietDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    PhieuXuatNhapSanPhamChiTietDal.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 sản phẩm xuất nhập chi tiết {0}", item.HH_Ten,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.HH_Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "search":
            #region search
            var list = PhieuXuatNhapSanPhamDal.SelectAll();
            rendertext(JavaScriptConvert.SerializeObject(list), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged = Security.IsAuthenticated();
        var Id     = Request["Id"];
        var IdNull = string.IsNullOrEmpty(Id);

        var DM_ID   = Request["DM_ID"];
        var Ma      = Request["Ma"];
        var Ten     = Request["Ten"];
        var MoTa    = Request["MoTa"];
        var GNY     = Request["GNY"];
        var GiaMin  = Request["GiaMin"];
        var GiaMax  = Request["GiaMax"];
        var Anh     = Request["Anh"];
        var DichVu  = Request["DichVu"];
        var KhoVay  = Request["KhoVay"];
        var HetHang = Request["HetHang"];
        var HongVay = Request["HongVay"];
        var refUrl  = Request["refUrl"];
        var q       = Request["q"];

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

        DichVu  = !string.IsNullOrEmpty(DichVu) ? "true" : "false";
        KhoVay  = !string.IsNullOrEmpty(KhoVay) ? "true" : "false";
        HetHang = !string.IsNullOrEmpty(HetHang) ? "true" : "false";
        HongVay = !string.IsNullOrEmpty(HongVay) ? "true" : "false";

        switch (subAct)
        {
        case "save":
            #region Thêm khách hàng
            if (logged)
            {
                var item = IdNull ? new HangHoa() : HangHoaDal.SelectById(new Guid(Id));
                item.Ten          = Ten;
                item.Ma           = Ma;
                item.Anh          = Anh;
                item.MoTa         = MoTa;
                item.NguoiCapNhat = Security.UserId;
                item.NgayCapNhat  = DateTime.Now;
                if (!string.IsNullOrEmpty(GNY))
                {
                    item.GNY = Convert.ToDouble(GNY);
                }
                if (!string.IsNullOrEmpty(GiaMin))
                {
                    item.GiaMin = Convert.ToDouble(GiaMin);
                }
                if (!string.IsNullOrEmpty(GiaMax))
                {
                    item.GiaMax = Convert.ToDouble(GiaMax);
                }
                if (!string.IsNullOrEmpty(DM_ID))
                {
                    item.DM_ID = new Guid(DM_ID);
                }
                item.KhoVay  = Convert.ToBoolean(KhoVay);
                item.DichVu  = Convert.ToBoolean(DichVu);
                item.HetHang = Convert.ToBoolean(HetHang);
                item.HongVay = Convert.ToBoolean(HongVay);
                if (IdNull)
                {
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.UserId;
                    item.ID       = Guid.NewGuid();
                    item          = HangHoaDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} thêm mới hàng hóa {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = HangHoaDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} sửa hàng hóa {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        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 khách hàng
            if (logged && !IdNull)
            {
                var item = HangHoaDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    HangHoaDal.DeleteById(new Guid(Id));
                    //SearchManager.Remove(Id);
                    TimKiemDal.DeleteByPRowId(DAL.con(), item.ID);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} xóa khách hàng {1}-{0}", item.Ten, item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ten
                        ,
                        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 = HangHoaDal.TimNhanh(q, 10);
            rendertext(JavaScriptConvert.SerializeObject(pg), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }