Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var NDTC_ID       = Request["NDTC_ID"];
        var CQ_ID         = Request["CQ_ID"];
        var MaPhieu       = Request["MaPhieu"];
        var SoPhieu       = Request["SoPhieu"];
        var SoPhieuAll    = Request["SoPhieuAll"];
        var SoTien        = Request["SoTien"];
        var Mota          = Request["Mota"];
        var NgayTrenPhieu = Request["NgayTrenPhieu"];
        var NgayTao       = Request["NgayTao"];
        var NguoiTao      = Request["NguoiTao"];
        var NgayCapNhat   = Request["NgayCapNhat"];
        var NguoiCapNhat  = Request["NguoiCapNhat"];
        var LoaiQuy       = Request["LoaiQuy"];
        var LoaiCandoi    = Request["LoaiCandoi"];
        var isCandoi      = Request["isCandoi"];
        var Thu           = Request["Thu"];
        var XN_ID         = Request["XN_ID"];
        var P_ID          = Request["P_ID"];
        var PDV_ID        = Request["PDV_ID"];
        var CTV_ID        = Request["CTV_ID"];
        var PGV_ID        = Request["PGV_ID"];
        var PBH_ID        = Request["PBH_ID"];
        var Xoa           = Request["Xoa"];
        var XoaAdm        = Request["XoaAdm"];

        XoaAdm = string.IsNullOrEmpty(XoaAdm) ? "false" : "true";
        Xoa    = string.IsNullOrEmpty(Xoa) ? "false" : "true";

        var logged = Security.IsAuthenticated();
        var Id     = Request["ID"];
        var IdNull = string.IsNullOrEmpty(Id);

        var refUrl = Request["refUrl"];

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

        switch (subAct)
        {
        case "save":
            #region Thêm Thu chi

            if (logged)
            {
                var item = ThuChiDal.SelectById(new Guid(Id));
                IdNull = item.ID == Guid.Empty;

                if (IdNull)
                {
                    item = new ThuChi {
                        ID = new Guid(Id), NgayTao = DateTime.Now, NguoiTao = Security.UserId, NguoiCapNhat = Security.UserId, NgayCapNhat = DateTime.Now
                    };
                }
                else
                {
                    item.NgayCapNhat  = DateTime.Now;
                    item.NguoiCapNhat = Security.UserId;
                }
                item.isCandoi = false;
                if (!string.IsNullOrEmpty(LoaiQuy))
                {
                    item.LoaiQuy = Convert.ToInt32(LoaiQuy);
                }
                if (!string.IsNullOrEmpty(NgayTrenPhieu))
                {
                    item.NgayTrenPhieu = Convert.ToDateTime(NgayTrenPhieu, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(SoTien))
                {
                    item.SoTien = Convert.ToDouble(SoTien);
                }
                if (!string.IsNullOrEmpty(P_ID))
                {
                    item.P_ID = new Guid(P_ID);
                }
                if (!string.IsNullOrEmpty(PDV_ID))
                {
                    item.PDV_ID = new Guid(PDV_ID);
                }

                if (!string.IsNullOrEmpty(CTV_ID))
                {
                    item.CTV_ID = new Guid(CTV_ID);
                }

                if (!string.IsNullOrEmpty(PGV_ID))
                {
                    item.PGV_ID = new Guid(PGV_ID);
                }
                if (!string.IsNullOrEmpty(PBH_ID))
                {
                    item.PBH_ID = new Guid(PBH_ID);
                }


                if (!string.IsNullOrEmpty(NDTC_ID))
                {
                    item.NDTC_ID = new Guid(NDTC_ID);
                }
                if (!string.IsNullOrEmpty(SoPhieu))
                {
                    item.SoPhieu = Convert.ToInt32(SoPhieu);
                }
                item.Thu = Convert.ToBoolean(Thu);

                item.Mota = Mota;

                if (IdNull)
                {
                    item = ThuChiDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới phiếu thu: {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = ThuChiDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa phiếu thu: {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                //SearchManager.Add(Ten, item.IndexNoiDung, item.IndexContent, Ten, item.ID.ToString(), item.Url, typeof(SuKien).Name);
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "remove":
            #region Xóa

            if (Security.IsAuthenticated())
            {
                var item = ThuChiDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    ThuChiDal.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("{1} xóa thu: {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        default: break;
        }
    }
Esempio n. 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var act             = Request["act"];
        var logged          = Security.IsAuthenticated();
        var Id              = Request["Id"];
        var IdNull          = string.IsNullOrEmpty(Id);
        var Ten             = Request["Ten"];
        var Ma              = Request["Ma"];
        var DanhGia         = Request["DanhGia"];
        var Mobile          = Request["Mobile"];
        var Ym              = Request["Ym"];
        var FacebookUid     = Request["FacebookUid"];
        var NguonGoc_ID     = Request["NguonGoc_ID"];
        var KhuVuc_ID       = Request["KhuVuc_ID"];
        var LinhVuc_ID      = Request["LinhVuc_ID"];
        var NgungTheoDoi    = Request["NgungTheoDoi"];
        var ThoiGianGoiDien = Request["ThoiGianGoiDien"];
        var DiaChi          = Request["DiaChi"];
        var Anh             = Request["Anh"];
        var NgaySinh        = Request["NgaySinh"];
        var TiemNang        = Request["TiemNang"];
        var KH_ID           = Request["KH_ID"];
        var TT_ID           = Request["TT_ID"];
        var LOAI_ID         = Request["LOAI_ID"];
        var NoiDung         = Request["NoiDung"];
        var NgayBatDau      = Request["NgayBatDau"];
        var DM_ID           = Request["DM_ID"];
        var NhanVien        = Request["NhanVien"];
        var MoTa            = Request["MoTa"];
        var BoQua           = Request["BoQua"];
        var ThanhCong       = Request["ThanhCong"];
        var refUrl          = Request["refUrl"];
        var DV_ID           = Request["DV_ID"];
        var Gia             = Request["Gia"];
        var CK              = Request["CK"];
        var ThanhToan       = Request["ThanhToan"];
        var ConNo           = Request["ConNo"];
        var BaoHanh_ID      = Request["BaoHanh_ID"];
        var NgayLap         = Request["NgayLap"];
        var NgayLam         = Request["NgayLam"];
        var TVDV_ID         = Request["TVDV_ID"];
        var ThuTu           = Request["ThuTu"];
        var SoLan           = Request["SoLan"];
        var GhiChu          = Request["GhiChu"];
        var NgayBatDau_Gio  = Request["NgayBatDau_Gio"];
        var NgayKetThuc_Gio = Request["NgayKetThuc_Gio"];

        if (!string.IsNullOrEmpty(refUrl))
        {
            refUrl = Server.UrlDecode(refUrl);
        }
        NgungTheoDoi = !string.IsNullOrEmpty(NgungTheoDoi) ? "true" : "false";
        BoQua        = !string.IsNullOrEmpty(BoQua) ? "true" : "false";
        ThanhCong    = !string.IsNullOrEmpty(ThanhCong) ? "true" : "false";
        switch (subAct)
        {
        case "save":
            #region Thêm lịch hẹn

            if (Security.IsAuthenticated())
            {
                SuKien item;
                if (IdNull)
                {
                    item = new SuKien {
                        ID = Guid.NewGuid(), NgayTao = DateTime.Now, NguoiTao = Security.Username, NguoiCapNhat = Security.Username, NgayCapNhat = DateTime.Now
                    };
                }
                else
                {
                    item = SuKienDal.SelectById(new Guid(Id));
                }
                item.Ten  = Ten;
                item.MoTa = MoTa;
                if (!string.IsNullOrEmpty(NgayBatDau) && !string.IsNullOrEmpty(NgayBatDau_Gio))
                {
                    item.NgayBatDau = Convert.ToDateTime(string.Format("{0} {1}", NgayBatDau, NgayBatDau_Gio), new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NgayBatDau) && !string.IsNullOrEmpty(NgayKetThuc_Gio))
                {
                    item.NgayKetThuc = Convert.ToDateTime(string.Format("{0} {1}", NgayBatDau, NgayKetThuc_Gio), new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(KH_ID))
                {
                    item.KH_ID = new Guid(KH_ID);
                }
                if (!string.IsNullOrEmpty(DM_ID))
                {
                    item.DM_ID = new Guid(DM_ID);
                }
                item.BoQua     = Convert.ToBoolean(BoQua);
                item.ThanhCong = Convert.ToBoolean(ThanhCong);
                item.NhanVien  = NhanVien;
                if (IdNull)
                {
                    item = SuKienDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới lịch hẹn: {0}", item.Ten,
                                          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 = SuKienDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa lịch hẹn: {0}", item.Ten,
                                          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
                }
                //SearchManager.Add(Ten, item.IndexNoiDung, item.IndexContent, Ten, item.ID.ToString(), item.Url, typeof(SuKien).Name);
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "LichHen-Xoa":
            #region Xóa lịch hẹn

            if (Security.IsAuthenticated())
            {
                var item = SuKienDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.Username)
                {
                    SuKienDal.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("{1} xóa lịch hẹn: {0}", item.Ten,
                                          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
        default: break;
        }
    }
Esempio n. 3
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;
        }
    }
Esempio n. 4
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;
        }
    }
Esempio n. 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var logged = Security.IsAuthenticated();
        var Id     = Request["Id"];
        var IdNull = string.IsNullOrEmpty(Id);

        var KH_ID            = Request["KH_ID"];
        var Ma               = Request["Ma"];
        var Tong             = Request["Tong"];
        var DatCong          = Request["DatCong"];
        var ThanhToan        = Request["ThanhToan"];
        var ConNo            = Request["ConNo"];
        var Ngay             = Request["Ngay"];
        var NgayBatDau       = Request["NgayBatDau"];
        var NgayKetThuc      = Request["NgayKetThuc"];
        var NgayTraVayThucTe = Request["NgayTraVayThucTe"];
        var ThuKho           = Request["ThuKho"];
        var NguoiXuat        = Request["NguoiXuat"];
        var NguoiNhap        = Request["NguoiNhap"];
        var NguoiTao         = Request["NguoiTao"];
        var NgayTao          = Request["NgayTao"];
        var NguoiCapNhat     = Request["NguoiCapNhat"];
        var NgayCapNhat      = Request["NgayCapNhat"];
        var TrangThai        = Request["TrangThai"];
        var GiayTo           = Request["GiayTo"];
        var DaTraGiayTo      = Request["DaTraGiayTo"];

        DaTraGiayTo = !string.IsNullOrEmpty(DaTraGiayTo) ? "true" : "false";

        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 = ChoThueVayDal.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(Tong))
                {
                    item.Tong = Convert.ToDouble(Tong);
                }
                if (!string.IsNullOrEmpty(DatCong))
                {
                    item.DatCong = Convert.ToDouble(DatCong);
                }
                item.GiayTo      = GiayTo;
                item.DaTraGiayTo = Convert.ToBoolean(DaTraGiayTo);
                if (!string.IsNullOrEmpty(Ma))
                {
                    item.Ma = Convert.ToInt32(Ma);
                }
                if (!string.IsNullOrEmpty(TrangThai))
                {
                    item.TrangThai = Convert.ToInt32(TrangThai);
                }
                if (!string.IsNullOrEmpty(KH_ID))
                {
                    item.KH_ID = new Guid(KH_ID);
                }


                if (!string.IsNullOrEmpty(Ngay))
                {
                    item.Ngay = Convert.ToDateTime(Ngay, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NgayBatDau))
                {
                    item.NgayBatDau = Convert.ToDateTime(NgayBatDau, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NgayKetThuc))
                {
                    item.NgayKetThuc = Convert.ToDateTime(NgayKetThuc, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NgayTraVayThucTe))
                {
                    item.NgayTraVayThucTe = Convert.ToDateTime(NgayTraVayThucTe, 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 = ChoThueVayDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới phiếu cho thuê váy: {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 = ChoThueVayDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa phiếu cho thuê váy: {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 = ChoThueVayDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    ChoThueVayDal.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 cho thuê váy: {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 = ChoThueVayDal.pagerNormal(DAL.con(), null, false, "CTV_Ma desc", q, 10, null, null);
            rendertext(JavaScriptConvert.SerializeObject(pg.List), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }
Esempio n. 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var act             = Request["act"];
        var logged          = Security.IsAuthenticated();
        var Id              = Request["Id"];
        var IdNull          = string.IsNullOrEmpty(Id);
        var Ten             = Request["Ten"];
        var Ma              = Request["Ma"];
        var DanhGia         = Request["DanhGia"];
        var Mobile          = Request["Mobile"];
        var Email           = Request["Email"];
        var Ym              = Request["Ym"];
        var FacebookUid     = Request["FacebookUid"];
        var NguonGoc_ID     = Request["NguonGoc_ID"];
        var KhuVuc_ID       = Request["KhuVuc_ID"];
        var XungHo          = Request["XungHo"];
        var LinhVuc_ID      = Request["LinhVuc_ID"];
        var NgungTheoDoi    = Request["NgungTheoDoi"];
        var ThoiGianGoiDien = Request["ThoiGianGoiDien"];
        var CMND            = Request["CMND"];
        var CMND_NgayCap    = Request["CMND_NgayCap"];
        var CMND_NoiCap     = Request["CMND_NoiCap"];
        var DiaChi          = Request["DiaChi"];
        var Anh             = Request["Anh"];
        var NgaySinh        = Request["NgaySinh"];
        var NgayCuoi        = Request["NgayCuoi"];
        var TiemNang        = Request["TiemNang"];
        var BoQua           = Request["BoQua"];
        var ThanhCong       = Request["ThanhCong"];
        var refUrl          = Request["refUrl"];
        var q = Request["q"];

        if (!string.IsNullOrEmpty(refUrl))
        {
            refUrl = Server.UrlDecode(refUrl);
        }
        NgungTheoDoi = !string.IsNullOrEmpty(NgungTheoDoi) ? "true" : "false";
        BoQua        = !string.IsNullOrEmpty(BoQua) ? "true" : "false";
        ThanhCong    = !string.IsNullOrEmpty(ThanhCong) ? "true" : "false";
        switch (subAct)
        {
        case "save":
            #region Thêm khách hàng
            if (logged)
            {
                var item = IdNull ? new KhachHang() : KhachHangDal.SelectById(new Guid(Id));
                item.Ten             = Ten;
                item.Ma              = Ma;
                item.Anh             = Anh;
                item.ThoiGianGoiDien = ThoiGianGoiDien;
                item.Mobile          = Mobile;
                item.FacebookUid     = FacebookUid;
                item.NgungTheoDoi    = Convert.ToBoolean(NgungTheoDoi);
                item.NguoiCapNhat    = Security.Username;
                item.NgayCapNhat     = DateTime.Now;
                item.DiaChi          = DiaChi;
                item.Ym              = Ym;
                item.TiemNang        = Convert.ToBoolean(TiemNang);
                item.CMND            = CMND;
                item.XungHo          = XungHo;
                item.CMND_NoiCap     = CMND_NoiCap;
                if (!string.IsNullOrEmpty(CMND_NgayCap))
                {
                    item.CMND_NgayCap = Convert.ToDateTime(CMND_NgayCap, new CultureInfo("vi-vn"));
                }

                if (!string.IsNullOrEmpty(NgaySinh))
                {
                    item.NgaySinh = Convert.ToDateTime(NgaySinh, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NgayCuoi))
                {
                    item.NgayCuoi = Convert.ToDateTime(NgayCuoi, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NguonGoc_ID))
                {
                    item.NguonGoc_ID = new Guid(NguonGoc_ID);
                }
                if (!string.IsNullOrEmpty(KhuVuc_ID))
                {
                    item.KhuVuc_ID = new Guid(KhuVuc_ID);
                }
                if (!string.IsNullOrEmpty(LinhVuc_ID))
                {
                    item.LinhVuc_ID = new Guid(LinhVuc_ID);
                }
                item.DanhGia = Convert.ToInt16(DanhGia);
                if (IdNull)
                {
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.ID       = Guid.NewGuid();
                    item          = KhachHangDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} thêm mới 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 = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = KhachHangDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} sử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 = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                //SearchManager.Add(Ten,string.Format("Khách hàng: {0}, Mobile: {1}, Địa chỉ: {2}"
                //    , Ten, Mobile, DiaChi),item.IndexContent, Ten,item.ID.ToString(),item.Url,typeof(KhachHang).Name);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "quickSave":
            #region Thêm khách hàng nhanh
            if (logged)
            {
                var item = IdNull ? new KhachHang() : KhachHangDal.SelectById(new Guid(Id));
                item.Ten          = Ten;
                item.Ma           = Ma;
                item.Mobile       = Mobile;
                item.Email        = Email;
                item.NguoiCapNhat = Security.Username;
                item.NgayCapNhat  = DateTime.Now;
                item.DiaChi       = DiaChi;
                if (!string.IsNullOrEmpty(NguonGoc_ID))
                {
                    item.NguonGoc_ID = new Guid(NguonGoc_ID);
                }
                if (IdNull)
                {
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.ID       = Guid.NewGuid();
                    item          = KhachHangDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} thêm mới 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 = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = KhachHangDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} sử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 = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                rendertext(string.Format("({0})", JavaScriptConvert.SerializeObject(item)));
            }
            break;

            #endregion
        case "remove":
            #region Xóa khách hàng
            if (logged && !IdNull)
            {
                var item = KhachHangDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.Username)
                {
                    KhachHangDal.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 pgTiemNang = KhachHangDal.pagerAll(null, false, "KH_NgayTao desc", q, 20, null, null, null, "0");
            rendertext(JavaScriptConvert.SerializeObject(pgTiemNang.List), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }
Esempio n. 7
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;
        }
    }
Esempio n. 8
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 KH_ID                = Request["KH_ID"];
        var GDV_ID               = Request["GDV_ID"];
        var TongTien             = Request["TongTien"];
        var ChietKhau            = Request["ChietKhau"];
        var DatCoc               = Request["DatCoc"];
        var ThanhToan            = Request["ThanhToan"];
        var ConNo                = Request["ConNo"];
        var TuVanVien            = Request["TuVanVien"];
        var NgayTuVan            = Request["NgayTuVan"];
        var CHUP_NhanVien        = Request["CHUP_NhanVien"];
        var CHUP_NgayBatDau      = Request["CHUP_NgayBatDau"];
        var CHUP_NgayKetThuc     = Request["CHUP_NgayKetThuc"];
        var CHUP_DiaDiem         = Request["CHUP_DiaDiem"];
        var CHUP_LoaiAlbum       = Request["CHUP_LoaiAlbum"];
        var CHUP_YeuCauKhach     = Request["CHUP_YeuCauKhach"];
        var CHUP_DaChuyenAnh     = Request["CHUP_DaChuyenAnh"];
        var CHUP_DaChuyenAnh_U   = Request["CHUP_DaChuyenAnh_U"];
        var CHUP_NgayChuyenAnh   = Request["CHUP_NgayChuyenAnh"];
        var TD_NhanVien          = Request["TD_NhanVien"];
        var TD_NgayBatDau        = Request["TD_NgayBatDau"];
        var TD_NgayKetThuc       = Request["TD_NgayKetThuc"];
        var TOC_NhanVien         = Request["TOC_NhanVien"];
        var TOC_NgayBatDau       = Request["TOC_NgayBatDau"];
        var TOC_NgayKetThuc      = Request["TOC_NgayKetThuc"];
        var TD_DiaDiem           = Request["TD_DiaDiem"];
        var TD_KhoangCach        = Request["TD_KhoangCach"];
        var TD_PhiDiLai          = Request["TD_PhiDiLai"];
        var TD_KhoanPhaiThu      = Request["TD_KhoanPhaiThu"];
        var PTS_NhanVien         = Request["PTS_NhanVien"];
        var PTS_NhanVienDaNhan   = Request["PTS_NhanVienDaNhan"];
        var PTS_NhanVienDaNhan_U = Request["PTS_NhanVienDaNhan_U"];
        var PTS_NgayXemMaket     = Request["PTS_NgayXemMaket"];
        var PTS_NgayBatDau       = Request["PTS_NgayBatDau"];
        var PTS_NgayKetThuc      = Request["PTS_NgayKetThuc"];
        var PTS_YeuCauKhachHang  = Request["PTS_YeuCauKhachHang"];
        var PTS_HenSanPham       = Request["PTS_HenSanPham"];
        var PTS_DaCoSanPham      = Request["PTS_DaCoSanPham"];
        var PTS_DaCoSanPham_U    = Request["PTS_DaCoSanPham_U"];
        var PTS_NgayCoSanPham    = Request["PTS_NgayCoSanPham"];
        var PTS_NgayLaySanPham   = Request["PTS_NgayLaySanPham"];
        var PTS_AnhPhong         = Request["PTS_AnhPhong"];
        var PTS_AnhPhongGhiChu   = Request["PTS_AnhPhongGhiChu"];
        var PTS_AnhBan           = Request["PTS_AnhBan"];
        var PTS_AnhBanGhiChu     = Request["PTS_AnhBanGhiChu"];
        var PTS_AnhBanQuyCach    = Request["PTS_AnhBanQuyCach"];
        var PTS_AnhBia           = Request["PTS_AnhBia"];
        var PTS_CD3D             = Request["PTS_CD3D"];
        var PTS_CD3D_U           = Request["PTS_CD3D_U"];
        var PTS_AnhBiaMau        = Request["PTS_AnhBiaMau"];
        var PTS_ThuMuc           = Request["PTS_ThuMuc"];
        var HoanThanh            = Request["HoanThanh"];
        var HoanThanh_U          = Request["HoanThanh_U"];

        var Voucher        = Request["Voucher"];
        var Voucher_Ma     = Request["Voucher_Ma"];
        var NguoiTao       = Request["NguoiTao"];
        var NguoiCapNhat   = Request["NguoiCapNhat"];
        var NgayTao        = Request["NgayTao"];
        var NgayCapNhat    = Request["NgayCapNhat"];
        var Xoa            = Request["Xoa"];
        var TrangThai      = Request["TrangThai"];
        var Huy            = Request["Huy"];
        var LyDoHuy        = Request["LyDoHuy"];
        var NgayHuy        = Request["NgayHuy"];
        var TD_NgoaiCanh   = Request["TD_NgoaiCanh"];
        var TD_NgoaiCanh_U = Request["TD_NgoaiCanh_U"];

        var NhanVienHuy = Request["NhanVienHuy"];

        var DuyetEkip       = Request["DuyetEkip"];
        var DeNghiDuyetEkip = Request["DeNghiDuyetEkip"];

        var CHUP_NgayBatDau_Gio  = Request["CHUP_NgayBatDau_Gio"];
        var CHUP_NgayKetThuc_Gio = Request["CHUP_NgayKetThuc_Gio"];
        var TD_NgayBatDau_Gio    = Request["TD_NgayBatDau_Gio"];
        var TD_NgayKetThuc_Gio   = Request["TD_NgayKetThuc_Gio"];
        var TOC_NgayBatDau_Gio   = Request["TOC_NgayBatDau_Gio"];
        var TOC_NgayKetThuc_Gio  = Request["TOC_NgayKetThuc_Gio"];
        var PTS_NgayBatDau_Gio   = Request["PTS_NgayBatDau_Gio"];
        var PTS_NgayKetThuc_Gio  = Request["PTS_NgayKetThuc_Gio"];


        CHUP_DaChuyenAnh   = !string.IsNullOrEmpty(CHUP_DaChuyenAnh_U) ? string.IsNullOrEmpty(CHUP_DaChuyenAnh) ? "false" : "true" : "";
        PTS_NhanVienDaNhan = !string.IsNullOrEmpty(PTS_NhanVienDaNhan_U) ? string.IsNullOrEmpty(PTS_NhanVienDaNhan) ? "false" : "true" : "";
        PTS_CD3D           = !string.IsNullOrEmpty(PTS_CD3D_U) ? string.IsNullOrEmpty(PTS_CD3D) ? "false" : "true" : "";
        PTS_DaCoSanPham    = !string.IsNullOrEmpty(PTS_DaCoSanPham_U) ?  string.IsNullOrEmpty(PTS_DaCoSanPham) ? "false" : "true" : "";
        Huy          = string.IsNullOrEmpty(Huy) ? "false" : "true";
        HoanThanh    = !string.IsNullOrEmpty(HoanThanh_U) ? string.IsNullOrEmpty(HoanThanh) ? "false" : "true" : "";
        DuyetEkip    = string.IsNullOrEmpty(DuyetEkip) ? "false" : "true";
        TD_NgoaiCanh = !string.IsNullOrEmpty(TD_NgoaiCanh_U) ? string.IsNullOrEmpty(TD_NgoaiCanh) ? "false" : "true" : "";

        var refUrl = Request["refUrl"];

        if (!string.IsNullOrEmpty(refUrl))
        {
            refUrl = Server.UrlDecode(refUrl);
        }
        var q = Request["q"];

        switch (subAct)
        {
        case "save":
            #region Thêm phiếu dịch vụ

            if (Security.IsAuthenticated())
            {
                var item = PhieuDichVuDal.SelectById(DAL.con(), new Guid(Id));
                IdNull  = item.ID == Guid.Empty;
                item.ID = new Guid(Id);
                if (IdNull)
                {
                    item = new PhieuDichVu
                    {
                        ID       = new Guid(Id),
                        NgayTao  = DateTime.Now,
                        NguoiTao = Security.UserId
                    };
                }
                item.NguoiCapNhat = Security.UserId;
                item.NgayCapNhat  = DateTime.Now;

                if (Convert.ToBoolean(DuyetEkip))
                {
                    if (!item.DuyetEkip)
                    {
                        item.NgayDuyetEkip = DateTime.Now;
                        item.NguoiDuyet    = Security.UserId;
                    }
                }
                if (!string.IsNullOrEmpty(TD_NgoaiCanh))
                {
                    item.TD_NgoaiCanh = Convert.ToBoolean(TD_NgoaiCanh);
                }
                if (!string.IsNullOrEmpty(DeNghiDuyetEkip))
                {
                    item.DuyetEkip = Convert.ToBoolean(DuyetEkip);
                }
                if (!string.IsNullOrEmpty(Ma))
                {
                    item.Ma = Convert.ToInt32(Ma);
                }
                if (!string.IsNullOrEmpty(KH_ID))
                {
                    item.KH_ID = new Guid(KH_ID);
                }
                if (!string.IsNullOrEmpty(NgayTuVan))
                {
                    item.NgayTuVan = Convert.ToDateTime(NgayTuVan, new CultureInfo("vi-vn"));
                }

                if (!string.IsNullOrEmpty(TuVanVien))
                {
                    item.TuVanVien = Convert.ToInt32(TuVanVien);
                }
                if (!string.IsNullOrEmpty(GDV_ID))
                {
                    item.GDV_ID = new Guid(GDV_ID);
                }

                // Chup anh
                if (!string.IsNullOrEmpty(CHUP_NhanVien))
                {
                    item.CHUP_NhanVien = Convert.ToInt32(CHUP_NhanVien);
                }

                if (!string.IsNullOrEmpty(CHUP_NgayBatDau) && !string.IsNullOrEmpty(CHUP_NgayBatDau_Gio))
                {
                    item.CHUP_NgayBatDau = Convert.ToDateTime(string.Format("{0} {1}", CHUP_NgayBatDau, CHUP_NgayBatDau_Gio), new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(CHUP_NgayBatDau) && !string.IsNullOrEmpty(CHUP_NgayKetThuc_Gio))
                {
                    item.CHUP_NgayKetThuc = Convert.ToDateTime(string.Format("{0} {1}", CHUP_NgayBatDau, CHUP_NgayKetThuc_Gio), new CultureInfo("vi-vn"));
                }
                item.CHUP_DiaDiem     = CHUP_DiaDiem;
                item.CHUP_LoaiAlbum   = CHUP_LoaiAlbum;
                item.CHUP_YeuCauKhach = CHUP_YeuCauKhach;
                if (!string.IsNullOrEmpty(CHUP_DaChuyenAnh))
                {
                    item.CHUP_DaChuyenAnh = Convert.ToBoolean(CHUP_DaChuyenAnh);
                }
                item.Huy = Convert.ToBoolean(Huy);
                // Trang diem
                if (!string.IsNullOrEmpty(TD_NhanVien))
                {
                    item.TD_NhanVien = Convert.ToInt32(TD_NhanVien);
                }
                if (!string.IsNullOrEmpty(TD_NgayBatDau) && !string.IsNullOrEmpty(TD_NgayBatDau_Gio))
                {
                    item.TD_NgayBatDau = Convert.ToDateTime(string.Format("{0} {1}", TD_NgayBatDau, TD_NgayBatDau_Gio), new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(TD_NgayBatDau) && !string.IsNullOrEmpty(TD_NgayKetThuc_Gio))
                {
                    item.TD_NgayKetThuc = Convert.ToDateTime(string.Format("{0} {1}", TD_NgayBatDau, TD_NgayKetThuc_Gio), new CultureInfo("vi-vn"));
                }
                item.TD_DiaDiem = TD_DiaDiem;
                if (!string.IsNullOrEmpty(TD_KhoangCach))
                {
                    item.TD_KhoangCach = Convert.ToInt32(TD_KhoangCach);
                }
                if (!string.IsNullOrEmpty(TD_PhiDiLai))
                {
                    item.TD_PhiDiLai = Convert.ToDouble(TD_PhiDiLai);
                }
                if (!string.IsNullOrEmpty(TD_KhoanPhaiThu))
                {
                    item.TD_KhoanPhaiThu = Convert.ToDouble(TD_KhoanPhaiThu);
                }

                // Toc
                if (!string.IsNullOrEmpty(TOC_NhanVien))
                {
                    item.TOC_NhanVien = Convert.ToInt32(TOC_NhanVien);
                }
                if (!string.IsNullOrEmpty(TOC_NgayBatDau) && !string.IsNullOrEmpty(TOC_NgayBatDau_Gio))
                {
                    item.TOC_NgayBatDau = Convert.ToDateTime(string.Format("{0} {1}", TOC_NgayBatDau, TOC_NgayBatDau_Gio), new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(TOC_NgayBatDau) && !string.IsNullOrEmpty(TOC_NgayKetThuc_Gio))
                {
                    item.TOC_NgayKetThuc = Convert.ToDateTime(string.Format("{0} {1}", TOC_NgayBatDau, TOC_NgayKetThuc_Gio), new CultureInfo("vi-vn"));
                }

                // Photoshop
                if (!string.IsNullOrEmpty(PTS_NhanVien))
                {
                    item.PTS_NhanVien = Convert.ToInt32(PTS_NhanVien);
                }
                if (!string.IsNullOrEmpty(PTS_NgayBatDau))
                {
                    item.PTS_NgayBatDau = Convert.ToDateTime(PTS_NgayBatDau, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(PTS_NgayLaySanPham))
                {
                    item.PTS_NgayLaySanPham = Convert.ToDateTime(PTS_NgayLaySanPham, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(PTS_NgayKetThuc))
                {
                    item.PTS_NgayKetThuc = Convert.ToDateTime(PTS_NgayKetThuc, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(PTS_NhanVienDaNhan))
                {
                    item.PTS_NhanVienDaNhan = Convert.ToBoolean(PTS_NhanVienDaNhan);
                }

                if (!string.IsNullOrEmpty(PTS_NgayXemMaket))
                {
                    item.PTS_NgayXemMaket = Convert.ToDateTime(PTS_NgayXemMaket, new CultureInfo("vi-vn"));
                }
                item.PTS_AnhBiaMau       = PTS_AnhBiaMau;
                item.PTS_ThuMuc          = PTS_ThuMuc;
                item.PTS_YeuCauKhachHang = PTS_YeuCauKhachHang;
                item.PTS_AnhBia          = PTS_AnhBia;
                item.PTS_AnhPhong        = PTS_AnhPhong;
                item.PTS_AnhPhongGhiChu  = PTS_AnhPhongGhiChu;
                item.PTS_AnhBan          = PTS_AnhBan;
                item.PTS_AnhBanQuyCach   = PTS_AnhBanQuyCach;
                item.PTS_AnhBanGhiChu    = PTS_AnhBanGhiChu;
                if (!string.IsNullOrEmpty(PTS_CD3D))
                {
                    item.PTS_CD3D = Convert.ToBoolean(PTS_CD3D);
                }

                if (!string.IsNullOrEmpty(HoanThanh))
                {
                    item.HoanThanh = Convert.ToBoolean(HoanThanh);
                }

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

                if (!string.IsNullOrEmpty(TongTien))
                {
                    item.TongTien = Convert.ToDouble(TongTien);
                }
                if (!string.IsNullOrEmpty(DatCoc))
                {
                    item.DatCoc = Convert.ToDouble(DatCoc);
                }
                if (!string.IsNullOrEmpty(ConNo))
                {
                    item.ConNo = Convert.ToDouble(ConNo);
                }

                // Huy + Trang Thai
                if (!string.IsNullOrEmpty(TrangThai))
                {
                    item.TrangThai = Convert.ToInt32(TrangThai);
                }
                if (!string.IsNullOrEmpty(NgayHuy))
                {
                    item.NgayHuy = Convert.ToDateTime(NgayHuy, new CultureInfo("vi-vn"));
                }
                item.LyDoHuy = LyDoHuy;
                if (!string.IsNullOrEmpty(NhanVienHuy))
                {
                    item.NhanVienHuy = Convert.ToInt32(NhanVienHuy);
                }


                if (IdNull)
                {
                    item = PhieuDichVuDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới 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 = PhieuDichVuDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa 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
                }
                //SearchManager.Add(Ten, item.IndexNoiDung, item.IndexContent, Ten, item.ID.ToString(), item.Url, typeof(SuKien).Name);
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "saveDuyetAnh":
            #region Lưu nhanh phiếu dịch vụ khi khách hàng duyệt ảnh

            if (Security.IsAuthenticated())
            {
                var item = PhieuDichVuDal.SelectById(DAL.con(), new Guid(Id));
                item.PTS_AnhBiaMau       = PTS_AnhBiaMau;
                item.PTS_YeuCauKhachHang = PTS_YeuCauKhachHang;
                item.PTS_AnhBia          = PTS_AnhBia;
                item.PTS_AnhPhong        = PTS_AnhPhong;
                item.PTS_AnhPhongGhiChu  = PTS_AnhPhongGhiChu;
                item.PTS_AnhBan          = PTS_AnhBan;
                item.PTS_AnhBanQuyCach   = PTS_AnhBanQuyCach;
                item.PTS_AnhBanGhiChu    = PTS_AnhBanGhiChu;

                item.NgayCapNhat  = DateTime.Now;
                item.NguoiCapNhat = Security.UserId;

                item = PhieuDichVuDal.Update(item);
                #region log
                LogDal.log(item, new Log()
                {
                    Checked = false
                    ,
                    Info =
                        string.Format("{1} sửa 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
                //SearchManager.Add(Ten, item.IndexNoiDung, item.IndexContent, Ten, item.ID.ToString(), item.Url, typeof(SuKien).Name);
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "remove":
            #region Xóa phiếu dịch vụ

            if (logged)
            {
                var item = PhieuDichVuDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao != 0)
                {
                    item.Xoa          = true;
                    item.NgayCapNhat  = DateTime.Now;
                    item.NguoiCapNhat = Security.UserId;
                    PhieuDichVuDal.Update(item);
                    //SearchManager.Remove(Id);
                    TimKiemDal.DeleteByPRowId(DAL.con(), item.ID);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} xóa 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 "removeAdm":
            #region Xóa phiếu dịch vụ

            if (Security.IsAuthenticated())
            {
                var item = PhieuDichVuDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    item.XoaAdm       = true;
                    item.NgayCapNhat  = DateTime.Now;
                    item.NguoiCapNhat = Security.UserId;
                    PhieuDichVuDal.Update(item);
                    //SearchManager.Remove(Id);
                    TimKiemDal.DeleteByPRowId(DAL.con(), item.ID);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} xóa 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 "restore":
            #region khôi phục phiếu dịch vụ

            if (Security.IsAuthenticated())
            {
                var item = PhieuDichVuDal.SelectById(DAL.con(), new Guid(Id));
                if (item.NguoiTao == Security.UserId)
                {
                    item.Xoa          = false;
                    item.XoaAdm       = false;
                    item.NgayCapNhat  = DateTime.Now;
                    item.NguoiCapNhat = Security.UserId;
                    PhieuDichVuDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} khôi phục 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 = "Khôi phục"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "search":
            #region search
            var pg = PhieuDichVuDal.TimNhanh(DAL.con(), q, "10");
            rendertext(JavaScriptConvert.SerializeObject(pg), "text/javascript");
            break;

            #endregion
        default: break;
        }
    }
Esempio n. 9
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;
        }
    }
Esempio n. 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var act             = Request["act"];
        var logged          = Security.IsAuthenticated();
        var Id              = Request["Id"];
        var IdNull          = string.IsNullOrEmpty(Id);
        var Ten             = Request["Ten"];
        var Ma              = Request["Ma"];
        var DanhGia         = Request["DanhGia"];
        var Mobile          = Request["Mobile"];
        var Ym              = Request["Ym"];
        var FacebookUid     = Request["FacebookUid"];
        var NguonGoc_ID     = Request["NguonGoc_ID"];
        var KhuVuc_ID       = Request["KhuVuc_ID"];
        var LinhVuc_ID      = Request["LinhVuc_ID"];
        var NgungTheoDoi    = Request["NgungTheoDoi"];
        var ThoiGianGoiDien = Request["ThoiGianGoiDien"];
        var DiaChi          = Request["DiaChi"];
        var Anh             = Request["Anh"];
        var NgaySinh        = Request["NgaySinh"];
        var TiemNang        = Request["TiemNang"];
        var KH_ID           = Request["KH_ID"];
        var TT_ID           = Request["TT_ID"];
        var LOAI_ID         = Request["LOAI_ID"];
        var NoiDung         = Request["NoiDung"];
        var NgayBatDau      = Request["NgayBatDau"];
        var DM_ID           = Request["DM_ID"];
        var NhanVien        = Request["NhanVien"];
        var MoTa            = Request["MoTa"];
        var BoQua           = Request["BoQua"];
        var ThanhCong       = Request["ThanhCong"];
        var refUrl          = Request["refUrl"];
        var DV_ID           = Request["DV_ID"];
        var Gia             = Request["Gia"];
        var CK              = Request["CK"];
        var ThanhToan       = Request["ThanhToan"];
        var ConNo           = Request["ConNo"];
        var BaoHanh_ID      = Request["BaoHanh_ID"];
        var NgayLap         = Request["NgayLap"];
        var NgayLam         = Request["NgayLam"];
        var TVDV_ID         = Request["TVDV_ID"];
        var ThuTu           = Request["ThuTu"];
        var SoLan           = Request["SoLan"];
        var GhiChu          = Request["GhiChu"];

        if (!string.IsNullOrEmpty(refUrl))
        {
            refUrl = Server.UrlDecode(refUrl);
        }
        NgungTheoDoi = !string.IsNullOrEmpty(NgungTheoDoi) ? "true" : "false";
        BoQua        = !string.IsNullOrEmpty(BoQua) ? "true" : "false";
        ThanhCong    = !string.IsNullOrEmpty(ThanhCong) ? "true" : "false";
        switch (act)
        {
        case "KhachHang-Add":
            #region Thêm khách hàng
            if (logged)
            {
                var item = IdNull ? new KhachHang() : KhachHangDal.SelectById(new Guid(Id));
                item.Ten             = Ten;
                item.Ma              = Ma;
                item.Anh             = Anh;
                item.ThoiGianGoiDien = ThoiGianGoiDien;
                item.Mobile          = Mobile;
                item.FacebookUid     = FacebookUid;
                item.NgungTheoDoi    = Convert.ToBoolean(NgungTheoDoi);
                item.NguoiCapNhat    = Security.Username;
                item.NgayCapNhat     = DateTime.Now;
                item.DiaChi          = DiaChi;
                item.Ym              = Ym;
                item.TiemNang        = Convert.ToBoolean(TiemNang);
                if (!string.IsNullOrEmpty(NgaySinh))
                {
                    item.NgaySinh = Convert.ToDateTime(NgaySinh, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(NguonGoc_ID))
                {
                    item.NguonGoc_ID = new Guid(NguonGoc_ID);
                }
                if (!string.IsNullOrEmpty(KhuVuc_ID))
                {
                    item.KhuVuc_ID = new Guid(KhuVuc_ID);
                }
                if (!string.IsNullOrEmpty(LinhVuc_ID))
                {
                    item.LinhVuc_ID = new Guid(LinhVuc_ID);
                }
                item.DanhGia = Convert.ToInt16(DanhGia);
                if (IdNull)
                {
                    item.NgayTao  = DateTime.Now;
                    item.NguoiTao = Security.Username;
                    item.ID       = Guid.NewGuid();
                    item          = KhachHangDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} thêm mới 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 = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = KhachHangDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{2} sử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 = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "KhachHang-Xoa":
            #region Xóa khách hàng
            if (logged && !IdNull)
            {
                var item = KhachHangDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.Username)
                {
                    KhachHangDal.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 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 "KhachHang-UpgradeFromTiemNang":
            #region Nâng cấp tiềm năng thành khách hàng
            if (logged && !IdNull)
            {
                var item = KhachHangDal.SelectById(new Guid(Id));
                item.TiemNang    = false;
                item.NgayCapNhat = DateTime.Now;
                KhachHangDal.Update(item);

                #region log
                LogDal.log(item, new Log()
                {
                    Checked = false
                    ,
                    Info =
                        string.Format("{2} chuyển đổi tiềm năng thành 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 = 4
                    ,
                    Ten = "Chuyển đổi"
                });
                #endregion
                rendertext(Id);
            }
            break;

            #endregion
        case "ChamSoc-Add":
            #region Thêm chăm sóc

            if (Security.IsAuthenticated())
            {
                ChamSoc item;
                if (IdNull)
                {
                    item = new ChamSoc {
                        ID = Guid.NewGuid(), NgayTao = DateTime.Now, NguoiTao = Security.Username
                    };
                    item.NgayTao = DateTime.Now;
                }
                else
                {
                    item = ChamSocDal.SelectById(new Guid(Id));
                }
                item.Ma = Ma;

                if (!string.IsNullOrEmpty(KH_ID))
                {
                    item.KH_ID = new Guid(KH_ID);
                }
                if (!string.IsNullOrEmpty(TT_ID))
                {
                    item.TT_ID = new Guid(TT_ID);
                }
                if (!string.IsNullOrEmpty(LOAI_ID))
                {
                    item.LOAI_ID = new Guid(LOAI_ID);
                }
                item.NoiDung = NoiDung;
                if (IdNull)
                {
                    item = ChamSocDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới chăm sóc {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 1
                        ,
                        Ten = "Thêm"
                    });
                    #endregion
                }
                else
                {
                    item = ChamSocDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa chăm sóc {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 2
                        ,
                        Ten = "Sửa"
                    });
                    #endregion
                }
                TimKiemDal.Add(item, item.ID);
                rendertext(item.ID.ToString());
            }
            break;

            #endregion
        case "ChamSoc-Xoa":
            #region Xóa chăm sóc

            if (Security.IsAuthenticated())
            {
                var item = ChamSocDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.Username)
                {
                    ChamSocDal.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 chăm sóc {0}", item.Ma,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.Ma
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                else
                {
                    rendertext("0");
                }
            }
            break;

            #endregion
        case "LichHen-Add":
            #region Thêm lịch hẹn

            if (Security.IsAuthenticated())
            {
                SuKien item;
                if (IdNull)
                {
                    item = new SuKien {
                        ID = Guid.NewGuid(), NgayTao = DateTime.Now, NguoiTao = Security.Username, NguoiCapNhat = Security.Username, NgayCapNhat = DateTime.Now
                    };
                }
                else
                {
                    item = SuKienDal.SelectById(new Guid(Id));
                }
                item.Ten  = Ten;
                item.MoTa = MoTa;
                if (!string.IsNullOrEmpty(NgayBatDau))
                {
                    item.NgayBatDau = Convert.ToDateTime(NgayBatDau, new CultureInfo("vi-vn"));
                }
                if (!string.IsNullOrEmpty(KH_ID))
                {
                    item.KH_ID = new Guid(KH_ID);
                }
                if (!string.IsNullOrEmpty(DM_ID))
                {
                    item.DM_ID = new Guid(DM_ID);
                }
                item.BoQua     = Convert.ToBoolean(BoQua);
                item.ThanhCong = Convert.ToBoolean(ThanhCong);
                item.NhanVien  = NhanVien;
                if (IdNull)
                {
                    item = SuKienDal.Insert(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} thêm mới lịch hẹn: {0}", item.Ten,
                                          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 = SuKienDal.Update(item);
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} sửa lịch hẹn: {0}", item.Ten,
                                          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 "LichHen-Xoa":
            #region Xóa lịch hẹn

            if (Security.IsAuthenticated())
            {
                var item = SuKienDal.SelectById(new Guid(Id));
                if (item.NguoiTao == Security.Username)
                {
                    ChamSocDal.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 lịch hẹn: {0}", item.Ten,
                                          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 "Logout":
            #region logout this system
            Security.LogOut();
            break;

            #endregion
        default: break;
        }
    }