Ejemplo n.º 1
0
        public List <SuKien> getSuKienByKiHieu(String kiHieu)
        {
            SqlConnection conn = connectDatabase();

            conn.Open();
            List <SuKien> lst = new List <SuKien>();
            SuKien        e;
            SqlCommand    cmd = new SqlCommand("SELECT * FROM SuKien where KiHieu=@kihieu", conn);

            cmd.Parameters.AddWithValue("kihieu", kiHieu);
            SqlDataReader r = cmd.ExecuteReader();

            if (r.HasRows)
            {
                while (r.Read())
                {
                    e        = new SuKien();
                    e.KiHieu = r["KiHieu"].ToString();
                    e.MoTa   = r["MoTa"].ToString();
                    e.Kieu   = Convert.ToInt32(r["Kieu"]);
                    e.UrlImg = r["UrlImg"].ToString();
                    lst.Add(e);
                }
            }
            conn.Close();
            return(lst);
        }
Ejemplo n.º 2
0
 private void Click_btnThem(object sender, RoutedEventArgs e)
 {
     using (QuanLyDuLieu db = new QuanLyDuLieu())
     {
         PhanLoaiSuKien plsk = new PhanLoaiSuKien
         {
             TieuDe  = txbTieuDe.Text == "" ? "(Không có tiêu đề)" : txbTieuDe.Text,
             HienThi = true,
         };
         db.PhanLoaiSuKien.Add(plsk);
         db.SaveChanges();
         SuKien sk = new SuKien
         {
             TieuDe                = "###" + NguoiDungING.NguoiDungID + "***",
             ThoiGianBatDau        = DateTime.Now,
             ThoiGianKetThuc       = DateTime.Now,
             LapLai                = true,
             KhungThoiGianLap      = "",
             ThongBao              = true,
             ThoiGianThongBao      = 0,
             KhungThoiGianThongBao = "",
             Mau              = "",
             NoiDung          = "",
             NguoiDungID      = NguoiDungING.NguoiDungID,
             PhanLoaiSuKienID = plsk.PhanLoaiSuKienID,
         };
         db.SuKien.Add(sk);
         db.SaveChanges();
         txbTieuDe.Text = "";
         List <PhanLoaiSuKien> lplsk = db.PhanLoaiSuKien.ToList();
         loadDBtoDataGrid();
     }
 }
Ejemplo n.º 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var db = new HistorySoftwareEntities2();

            if (MessageBox.Show("Do you want to delete", "Confirm", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                for (int i = 0; i < this.dtlShow.SelectedRows.Count; i++)
                {
                    var row  = this.dtlShow.SelectedRows[i];
                    var item = (SuKien)row.DataBoundItem;

                    try
                    {
                        SuKien @class = db.SuKiens.Find(item.Id);
                        db.SuKiens.Remove(@class);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Cannot delete class: " + item.Id);
                    }
                    this.ShowList();
                }
            }
        }
Ejemplo n.º 4
0
        public JsonResult Add(SuKienModel m)
        {
            ResponseBase res = new ResponseBase();

            try
            {
                SuKien dt = new SuKien
                {
                    Ten     = m.Ten,
                    NoiDung = m.NoiDung,
                    DiaDiem = m.DiaDiem,
                    BatDau  = DateTime.Parse(m.BatDau),
                    GhiChu  = m.GhiChu
                };
                db.SuKiens.InsertOnSubmit(dt);
                db.SubmitChanges();
                res.Status  = StatusID.Success;
                res.Message = "Đã thêm sự kiện";
            }
            catch (Exception e)
            {
                res.Status  = StatusID.InternalServer;
                res.Message = e.Message;
            }
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
        public JsonResult Delete(int id)
        {
            SuKien obj = db.SuKiens.Find(id);

            db.SuKiens.Remove(obj);
            return(Json(db.SaveChanges()));
        }
Ejemplo n.º 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     var id = Request["ID"];
     var khId = Request["KH_ID"];
     SuKien Item;
     using (var con = DAL.con())
     {
         if (string.IsNullOrEmpty(id))
         {
             Item = new SuKien();
             if (!string.IsNullOrEmpty(khId))
             {
                 if (khId.Length > 36)
                 {
                     khId = khId.Substring(khId.LastIndexOf(',') + 1);
                 }
                 var kh = KhachHangDal.SelectById(new Guid(khId), con);
                 Item.KH_Ten = kh.Ten;
                 Item.KH_ID = kh.ID;
             }
             Add1.Item = Item;
         }
         else
         {
             Item = SuKienDal.SelectById(new Guid(id));
             Item.KH_Ten = maHoa.DecryptString(Item.KH_Ten, Item.KH_ID.ToString());
             Add1.Item = Item;
         }
         var listLoai = DanhMucDal.SelectByLDMMa(con, "NHOM-SK");
         Add1.ListLoai = listLoai;
     }
 }
Ejemplo n.º 7
0
        public ActionResult Detail(int id)
        {
            SuKien eve = mo.SuKiens.Find(id);

            return(View(eve));
            //         }
        }
Ejemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var    id   = Request["ID"];
        var    khId = Request["KH_ID"];
        SuKien Item;

        using (var con = DAL.con())
        {
            if (string.IsNullOrEmpty(id))
            {
                Item = new SuKien();
                if (!string.IsNullOrEmpty(khId))
                {
                    if (khId.Length > 36)
                    {
                        khId = khId.Substring(khId.LastIndexOf(',') + 1);
                    }
                    var kh = KhachHangDal.SelectById(new Guid(khId), con);
                    Item.KH_Ten = kh.Ten;
                    Item.KH_ID  = kh.ID;
                }
                ViewItem.Item = Item;
            }
            else
            {
                Item          = SuKienDal.SelectById(new Guid(id));
                Item.KH_Ten   = maHoa.DecryptString(Item.KH_Ten, Item.KH_ID.ToString());
                ViewItem.Item = Item;
            }
        }
    }
Ejemplo n.º 9
0
        private void Click_btnSua(object sender, RoutedEventArgs e)
        {
            try
            {
                using (QuanLyDuLieu db = new QuanLyDuLieu())
                {
                    if (comboBoxPhanLoaiSuKien.Items.Count == 0)
                    {
                        throw new Exception("khongCoPhanLoaiSuKien");
                    }
                    string   tieuDe      = txbTieuDe.Text == "" ? "(Không có tiêu đề)" : txbTieuDe.Text;
                    DateTime dateBatDau  = datePickerBatDau.SelectedDate == null ? DateTime.Now : (DateTime)datePickerBatDau.SelectedDate;
                    DateTime timeBatDau  = timePickerBatDau.SelectedTime == null ? new DateTime(1, 1, 1, 0, 0, 0) : (DateTime)timePickerBatDau.SelectedTime;
                    DateTime timeKetThuc = timePickerKetThuc.SelectedTime == null ? new DateTime(1, 1, 1, 23, 59, 0) : (DateTime)timePickerKetThuc.SelectedTime;
                    DateTime dateKetThuc = (datePickerKetThuc.SelectedDate == null || datePickerKetThuc.SelectedDate < datePickerBatDau.SelectedDate) ? (DateTime)datePickerBatDau.SelectedDate : (DateTime)datePickerKetThuc.SelectedDate;

                    DateTime thoiGianBatDau        = new DateTime(dateBatDau.Year, dateBatDau.Month, dateBatDau.Day, timeBatDau.Hour, timeBatDau.Minute, timeBatDau.Second);
                    DateTime thoiGianKetThuc       = new DateTime(dateKetThuc.Year, dateKetThuc.Month, dateKetThuc.Day, timeKetThuc.Hour, timeKetThuc.Minute, timeKetThuc.Second);
                    bool     lapLai                = checkBoxLapLai.IsChecked == null ? false : (bool)checkBoxLapLai.IsChecked;
                    string   khungThoiGianLap      = lapLai ? GetComboBoxKhungThoiGianLap() : "khonglap";
                    bool     thongBao              = checkBoxThongBao.IsChecked == null ? false : (bool)checkBoxThongBao.IsChecked;
                    string   khungThoiGianThongBao = thongBao ? GetComboBoxThongBao() : "khongThongBao";
                    int      thoiGianThongBao      = GetThoiGianThongBao(int.Parse(TxbThoiGian.Text), khungThoiGianThongBao);

                    string Mau     = ((Color)(comboBoxMau.SelectedItem as PropertyInfo).GetValue(null, null)).ToString();
                    string NoiDung = txbNoiDung.Text;

                    string nguoiDungID      = NguoiDungING.NguoiDungID;
                    int    phanLoaiSuKienID = ((PhanLoaiSuKien)comboBoxPhanLoaiSuKien.SelectionBoxItem).PhanLoaiSuKienID;

                    SuKien sk = db.SuKien.ToList().Single(m => m.SuKienID == SuKienING.SuKienID);
                    sk.TieuDe                = tieuDe;
                    sk.ThoiGianBatDau        = thoiGianBatDau;
                    sk.ThoiGianKetThuc       = thoiGianKetThuc;
                    sk.LapLai                = lapLai;
                    sk.KhungThoiGianLap      = khungThoiGianLap;
                    sk.ThongBao              = thongBao;
                    sk.KhungThoiGianThongBao = khungThoiGianThongBao;
                    sk.ThoiGianThongBao      = thoiGianThongBao;
                    sk.Mau              = Mau;
                    sk.NoiDung          = NoiDung;
                    sk.NguoiDungID      = nguoiDungID;
                    sk.PhanLoaiSuKienID = phanLoaiSuKienID;
                    db.SaveChanges();
                    MessageBox.Show("sửa dữ liệu thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                if (ex.Message == "khongCoPhanLoaiSuKien")
                {
                    MessageBox.Show("Xin mời thêm phân loại sự kiện.", "Thông báo lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                }
                else
                {
                    MessageBox.Show(ex.Message, "Thông báo lỗi", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Ejemplo n.º 10
0
 public ActionResult Edit(SuKien sk, string stringurl)
 {
     using (TuVanLaptopEntities db = new TuVanLaptopEntities())
     {
         db.Entry(sk).State = EntityState.Modified;
         db.SaveChanges();
         return(Redirect(stringurl));
     }
 }
Ejemplo n.º 11
0
        public async Task <ActionResult> SieuthiEditSukien(int?id)
        {
            if (id == null || id == 0)
            {
                return(RedirectToRoute("AdminPanel"));
            }
            SuKien _sukien = await db.SuKiens.FindAsync(id);

            if (_sukien == null)
            {
                return(RedirectToRoute("AdminPanel"));
            }
            List <string> danhsachanh = new List <string>();

            if (_sukien.DsAnh != null)
            {
                danhsachanh.AddRange(_sukien.DsAnh.Split(','));
            }
            if (danhsachanh.Count == 1)
            {
                danhsachanh.AddRange(new string[] { "", "", "", "" });
            }
            if (danhsachanh.Count == 2)
            {
                danhsachanh.AddRange(new string[] { "", "", "" });
            }
            if (danhsachanh.Count == 3)
            {
                danhsachanh.AddRange(new string[] { "", "" });
            }
            if (danhsachanh.Count == 4)
            {
                danhsachanh.AddRange(new string[] { "" });
            }
            if (danhsachanh.Count == 0)
            {
                danhsachanh.AddRange(new string[] { "", "", "", "", "" });
            }
            var arrayAnh  = danhsachanh.ToArray();
            var getSuKien = new SuKienModel()
            {
                SuKienId    = _sukien.SuKienId,
                SieuThiId   = _sukien.SieuThiId,
                ConfirmSend = (bool)_sukien.DaThongBao,
                TDSuKien    = _sukien.TDSuKien,
                NDSuKien    = _sukien.NDSuKien,
                indivanh1   = arrayAnh[0],
                indivanh2   = arrayAnh[1],
                indivanh3   = arrayAnh[2],
                indivanh4   = arrayAnh[3],
                indivanh5   = arrayAnh[4],
                NgayBD      = _sukien.NgayBD,
                NgayKT      = _sukien.NgayKT
            };

            return(View(getSuKien));
        }
Ejemplo n.º 12
0
        //lấy Id của sự kiện dựa vào Name(Bảng sự kiện)
        public String getSuKienId(string name)
        {
            SuKien sk = db.SuKiens.SingleOrDefault(n => n.Name == name);

            if (sk == null)
            {
                return(null);
            }
            return((sk.Id).ToString());
        }
        public ActionResult Edit(int?id)
        {
            SuKien obj = id > 0 ? db.SuKiens.Find(id) : new SuKien();

            if (obj == null)
            {
                return(HttpNotFound());
            }
            return(View(obj));
        }
Ejemplo n.º 14
0
 public SuKien suyDienTien()
 {
     progess  = "";
     TG       = GT;
     progess += "Ban đầu:" + Environment.NewLine + "TG = GT = {";
     foreach (SuKien e in TG)
     {
         progess += (e.KiHieu + ",");
     }
     progess += ("}" + Environment.NewLine);
     R        = luat_DAL.getAllLuat();
     getSAT();
     progess += "SAT={";
     foreach (Luat l in SAT)
     {
         progess += l.KiHieu + ", ";
     }
     progess += ("}" + Environment.NewLine);
     while (SAT.Count > 0 && getGoal() == null)
     {
         progess += ("SAT != rỗng và Goal không nằm trong TG" + Environment.NewLine);
         progess += (Environment.NewLine + "Lấy " + SAT[0].KiHieu + " để tiếp tục!" + Environment.NewLine);
         SuKien x = new SuKien(SAT[0].VePhai);
         if (!TG.Contains(x))
         {
             TG.Add(events[events.IndexOf(x)]);
         }
         int s = SAT.IndexOf(SAT[0]);
         int r = R.IndexOf(SAT[0]);
         SAT.RemoveAt(s);
         R.RemoveAt(r);
         getSAT();
         progess += ("TG = {");
         foreach (SuKien e in TG)
         {
             progess += (e.KiHieu + ",");
         }
         progess += ("}" + Environment.NewLine);
         progess += "SAT={";
         foreach (Luat l in SAT)
         {
             progess += l.KiHieu + ", ";
         }
         progess += ("}" + Environment.NewLine);
     }
     if (getGoal() == null)
     {
         progess += (Environment.NewLine + "SAT rỗng, Goal không thuộc TG=> Thất bại");
     }
     else
     {
         progess += (Environment.NewLine + "Goal= " + getGoal().KiHieu + " thuộc TG, =>Thành công");
     }
     return(getGoal());
 }
Ejemplo n.º 15
0
 private void Click_btnXoa(object sender, RoutedEventArgs e)
 {
     using (QuanLyDuLieu db = new QuanLyDuLieu())
     {
         SuKien sk = db.SuKien.ToList().Find(m => m.SuKienID == SuKienING.SuKienID);
         db.SuKien.Remove(sk);
         db.SaveChanges();
         MessageBox.Show("Xóa sự kiện thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
         this.Close();
     }
 }
Ejemplo n.º 16
0
 public ActionResult Edit(SuKien eve)
 {
     if (new EventCommon().Edit(eve))
     {
         ModelState.AddModelError("", "sửa Thành công!");
         return(Redirect("/Admin/EventAdmin/Index"));
     }
     else
     {
         ModelState.AddModelError("", "sửa không thành công");
         return(View());
     }
 }
Ejemplo n.º 17
0
 public ActionResult Edit(int id, string stringUrl)
 {
     using (TuVanLaptopEntities db = new TuVanLaptopEntities())
     {
         SuKien sk = db.SuKiens.SingleOrDefault(x => x.Id == id);
         if (sk == null)
         {
             return(null);
         }
         ViewBag.Url = stringUrl;
         return(View(sk));
     }
 }
Ejemplo n.º 18
0
        public List <SuKien> GetSuKienByOneDate(DateTime ngayCanXet)
        {
            List <SuKien> list = new List <SuKien>();

            DataTable data = DataProvider.Instance.ExecuteQuery("EXEC USP_GetSuKienByOneDate @ngayCanXet ", new object[] { ngayCanXet });

            foreach (DataRow item in data.Rows)
            {
                SuKien suKien = new SuKien(item);
                list.Add(suKien);
            }
            return(list);
        }
 public ActionResult Edit(SuKien obj)
 {
     obj.SaveFor(q => q.AnhNen);
     if (obj.IDSuKien > 0)
     {
         db.Entry(obj).State = EntityState.Modified;
     }
     else
     {
         db.SuKiens.Add(obj);
     }
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 20
0
 public bool Add(SuKien eve)
 {
     try
     {
         eve.DaXoa = 1;
         db.SuKiens.Add(eve);
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 21
0
        private SuKien getGoal()
        {
            SuKien s = null;

            for (int i = TG.Count - 1; i >= 0; i--)
            {
                if (TG[i].Kieu == 1)
                {
                    s = TG[i];
                    break;
                }
            }
            return(s);
        }
Ejemplo n.º 22
0
        public void insertSuKien(SuKien suKien)
        {
            SqlConnection conn = connectDatabase();

            conn.Open();
            SqlCommand cmd = new SqlCommand("insert into SuKien values(@kihieu, @kieu, @mota, @urlimg)", conn);

            cmd.Parameters.AddWithValue("kihieu", suKien.KiHieu);
            cmd.Parameters.AddWithValue("kieu", suKien.Kieu);
            cmd.Parameters.AddWithValue("mota", suKien.MoTa);
            cmd.Parameters.AddWithValue("urlimg", suKien.UrlImg);
            cmd.ExecuteNonQuery();

            conn.Close();
        }
Ejemplo n.º 23
0
 public bool Delete(int id)
 {
     try
     {
         SuKien _event = new SuKien();
         _event       = db.SuKiens.Find(id);
         _event.DaXoa = 1;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 24
0
 private void Click_btnXoa(object sender, RoutedEventArgs e)
 {
     if (dataGirdDSSuKien.SelectedIndex >= 0)
     {
         SuKien sk = (SuKien)dataGirdDSSuKien.SelectedItem;
         using (QuanLyDuLieu db = new QuanLyDuLieu())
         {
             SuKien skXoa = db.SuKien.ToList().Find(m => m.SuKienID == sk.SuKienID);
             db.SuKien.Remove(skXoa);
             db.SaveChanges();
             ListSuKienING = DateSuKien(NgayING);
             MessageBox.Show("Xoá sự kiện thành công !", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Information);
         }
     }
 }
Ejemplo n.º 25
0
        public void updateSuKien(SuKien suKien)
        {
            SqlConnection conn = connectDatabase();

            conn.Open();
            SqlCommand cmd = new SqlCommand("update SuKien set Kieu=@kieu, MoTa=@mota, UrlImg=@urlimg where KiHieu=@kihieu", conn);

            cmd.Parameters.AddWithValue("kihieu", suKien.KiHieu);
            cmd.Parameters.AddWithValue("kieu", suKien.Kieu);
            cmd.Parameters.AddWithValue("mota", suKien.MoTa);
            cmd.Parameters.AddWithValue("urlimg", suKien.UrlImg);
            cmd.ExecuteNonQuery();

            conn.Close();
        }
Ejemplo n.º 26
0
        private void Click_btnSua(object sender, RoutedEventArgs e)
        {
            if (dataGirdDSSuKien.SelectedIndex >= 0)
            {
                SuKien sk = (SuKien)dataGirdDSSuKien.SelectedItem;
                SuKien skSua;
                using (QuanLyDuLieu db = new QuanLyDuLieu())
                {
                    skSua = db.SuKien.ToList().Find(m => m.SuKienID == sk.SuKienID);
                }

                ThaoTacSuKien ttsk = new ThaoTacSuKien(NguoiDungING, skSua);
                ttsk.ShowDialog();
                ListSuKienING = DateSuKien(NgayING);
            }
        }
Ejemplo n.º 27
0
 public ActionResult Create(SuKien eve)
 {
     if (ModelState.IsValid)
     {
         EventCommon _event = new EventCommon();
         if (_event.Add(eve))
         {
             ModelState.AddModelError("", "Thêm Thành công!");
             return(Redirect("/Admin/EventAdmin/Index"));
         }
         else
         {
             ModelState.AddModelError("", "sửa Thành công!");
             return(View());
         }
     }
     return(View());
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Load dữ liệu lịch học từ database và đưa đến listSuKienUC để sau đó đưa vào lineTableUC
        /// </summary>
        private bool loadLichHocTrongNgay()
        {
            lichHocs = CHoatDong_BLL.loadLichHocTrongNgay(strMaSV);
            if (lichHocs == null)
            {
                listSuKienUC = null;
                return(false);
            }

            listSuKienUC = new List <SuKien>();
            foreach (DataRow dr in lichHocs.Rows)
            {
                Color  clSuKien = Color.FromArgb(int.Parse(dr["MauMucDo"].ToString()));
                SuKien sk       = new SuKien(clSuKien, DateTime.Parse(dr["GioBD"].ToString()), DateTime.Parse(dr["GioKT"].ToString()),
                                             CMonHoc_BLL.loadTenMon(dr["MaMon"].ToString()));
                listSuKienUC.Add(sk);
            }
            return(true);
        }
Ejemplo n.º 29
0
 public bool Edit(SuKien eve)
 {
     try
     {
         SuKien _event = new SuKien();
         _event          = db.SuKiens.Find(eve.IDEvent);
         _event.TieuDe   = eve.TieuDe;
         _event.HinhAnh  = eve.HinhAnh;
         _event.Thoigian = eve.Thoigian;
         _event.TomTat   = eve.TomTat;
         _event.NoiDung  = eve.NoiDung;
         db.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Ejemplo n.º 30
0
 public ThaoTacSuKien(NguoiDung nd, SuKien sk)
 {
     InitializeComponent();
     NguoiDungING = nd;
     SuKienING    = sk;
     using (QuanLyDuLieu db = new QuanLyDuLieu())
     {
         txbTieuDe.Text  = sk.TieuDe;
         txbNoiDung.Text = sk.NoiDung;
         datePickerBatDau.SelectedDate       = sk.ThoiGianBatDau;
         timePickerBatDau.SelectedTime       = sk.ThoiGianBatDau;
         datePickerKetThuc.SelectedDate      = sk.ThoiGianKetThuc;
         timePickerKetThuc.SelectedTime      = sk.ThoiGianKetThuc;
         comboBoxPhanLoaiSuKien.SelectedItem = (PhanLoaiSuKien)db.PhanLoaiSuKien.ToList().Find(m => m.PhanLoaiSuKienID == sk.PhanLoaiSuKienID);
         checkBoxLapLai.IsChecked            = sk.LapLai;
         checkBoxThongBao.IsChecked          = sk.ThongBao;
         TxbThoiGian.Text = sk.ThoiGianThongBao.ToString();
     }
     btnLuu.Visibility = Visibility.Hidden;
     LoadDefault();
 }
Ejemplo n.º 31
0
        public ActionResult SaveSuKien(SuKien sk)
        {
            using (TuVanLaptopEntities db = new TuVanLaptopEntities())
            {
                //sk chưa tồn tại ta mới thêm
                //if (SuKien.SaveSuKien(sk) != null)
                //{
                //nếu không  lưu thành công sk
                if (!SuKien.SaveSuKien(sk))
                {
                    TempData["ThongBao"] = "Đã tồn tại sự kiện";
                    //return Redirect(ControllerContext.HttpContext.Request.UrlReferrer.ToString());
                    return(View());
                }
                //nếu lưu thành công
                return(Json(sk));

                //}
                //return PartialView("ThemSuKienPartial", sk);
            }
        }
Ejemplo n.º 32
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;
        }
    }
Ejemplo n.º 33
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 "TuVanDichVu-Add":
                #region Thêm tư vấn dịch vụ

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

                    }
                    item.Ma = Ma;
                    item.Gia = Convert.ToDouble(Gia);
                    item.CK = Convert.ToDouble(CK);
                    item.ThanhToan = Convert.ToDouble(ThanhToan);
                    item.ConNo = Convert.ToDouble(ConNo);
                    item.SoLan = Convert.ToInt32(SoLan);
                    if (!string.IsNullOrEmpty(NgayLap))
                    {
                        item.NgayLap = Convert.ToDateTime(NgayLap, new CultureInfo("vi-vn"));
                    }
                    if (!string.IsNullOrEmpty(KH_ID))
                    {
                        item.KH_ID = new Guid(KH_ID);
                    }
                    if (!string.IsNullOrEmpty(BaoHanh_ID))
                    {
                        item.BaoHanh_ID = new Guid(BaoHanh_ID);
                    }
                    if (!string.IsNullOrEmpty(DV_ID))
                    {
                        item.DV_ID = new Guid(DV_ID);
                    }
                    item.GhiChu = GhiChu;
                    item.NhanVien = NhanVien;
                    if (IdNull)
                    {
                        item = TuVanDichVuDal.Insert(item);
                        #region log
                        LogDal.log(item, new Log()
                        {
                            Checked = false
                            ,
                            Info =
                                string.Format("{1} thêm mới tư vấn dịch vụ: {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 = TuVanDichVuDal.Update(item);
                        #region log
                        LogDal.log(item, new Log()
                        {
                            Checked = false
                            ,
                            Info =
                                string.Format("{1} sửa tư vấn dịch vụ: {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 "TuVanDichVu-Xoa":
                #region Xóa tư vấn dịch vụ

                if (Security.IsAuthenticated())
                {
                    var item = TuVanDichVuDal.SelectById(new Guid(Id));
                    if (item.NguoiTao == Security.Username)
                    {
                        TuVanDichVuDal.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 tư vấn dịch vụ: {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 "TuVanLamDichVu-Add":
                #region Thêm làm dịch vụ

                if (Security.IsAuthenticated())
                {
                    TuVanLamDichVu item;
                    if (IdNull)
                    {
                        item = new TuVanLamDichVu();
                    }
                    else
                    {
                        item = TuVanLamDichVuDal.SelectById(new Guid(Id));

                    }
                    item.ThuTu = Convert.ToInt32(ThuTu);
                    if (!string.IsNullOrEmpty(NgayLam))
                    {
                        item.NgayLam = Convert.ToDateTime(NgayLam, new CultureInfo("vi-vn"));
                    }
                    item.NhanVien = NhanVien;
                    if (IdNull)
                    {
                        item = TuVanLamDichVuDal.Insert(item);
                        #region log
                        LogDal.log(item, new Log()
                        {
                            Checked = false
                            ,
                            Info =
                                string.Format("{1} thêm mới làm dịch vụ: {0}", item.ID,
                                              Security.Username)
                            ,
                            NgayTao = DateTime.Now
                            ,
                            Username = Security.Username
                            ,
                            PRowId = item.ID
                            ,
                            PTen = string.Format("{1} thêm mới làm dịch vụ: {0}", item.ID,
                                              Security.Username)
                            ,
                            RequestIp = Request.UserHostAddress
                            ,
                            RawUrl = refUrl
                            ,
                            LLOG_ID = 1
                            ,
                            Ten = "Thêm"
                        });
                        #endregion
                    }
                    else
                    {
                        item = TuVanLamDichVuDal.Update(item);
                        #region log
                        LogDal.log(item, new Log()
                        {
                            Checked = false
                            ,
                            Info =
                                string.Format("{1} sửa làm dịch vụ: {0}", item.ID,
                                              Security.Username)
                            ,
                            NgayTao = DateTime.Now
                            ,
                            Username = Security.Username
                            ,
                            PRowId = item.ID
                            ,
                            PTen = string.Format("{1} sửa làm dịch vụ: {0}", item.ID,
                                              Security.Username)
                            ,
                            RequestIp = Request.UserHostAddress
                            ,
                            RawUrl = refUrl
                            ,
                            LLOG_ID = 2
                            ,
                            Ten = "Sửa"
                        });
                        #endregion
                    }
                    rendertext(item.ID.ToString());
                }
                break;

                #endregion
            case "TuVanLamDichVu-Xoa":
                #region Xóa làm dịch vụ

                if (Security.IsAuthenticated())
                {
                    var item = TuVanLamDichVuDal.SelectById(new Guid(Id));
                    TuVanDichVuDal.DeleteById(new Guid(Id));
                    #region log
                    LogDal.log(item, new Log()
                    {
                        Checked = false
                        ,
                        Info =
                            string.Format("{1} xóa làm dịch vụ: {0}", item.ID,
                                          Security.Username)
                        ,
                        NgayTao = DateTime.Now
                        ,
                        Username = Security.Username
                        ,
                        PRowId = item.ID
                        ,
                        PTen = item.ID.ToString()
                        ,
                        RequestIp = Request.UserHostAddress
                        ,
                        RawUrl = refUrl
                        ,
                        LLOG_ID = 3
                        ,
                        Ten = "Xóa"
                    });
                    #endregion
                    rendertext("1");
                }
                break;
                #endregion
            case "Logout":
                #region logout this system
                Security.LogOut();
                break;
                #endregion
            default:break;
        }
    }
Ejemplo n.º 34
0
        public override void KhoiTao(SqlConnection con, Page page)
        {
            var sb = new StringBuilder();
            var cs = page.ClientScript;
            var c = HttpContext.Current;
            var _id = c.Request["VID"];

            #region bien
            var ID = c.Request["ID"];
            var PID = c.Request["PID"];
            var KH_ID = c.Request["KH_ID"];
            var DM_ID = c.Request["DM_ID"];
            var Ten = c.Request["Ten"];
            var MoTa = c.Request["MoTa"];
            var NhanVien = c.Request["NhanVien"];
            var NgayBatDau = c.Request["NgayBatDau"];
            var NgayKetThuc = c.Request["NgayKetThuc"];
            var Ngay = c.Request["Ngay"];
            var Gio = c.Request["Gio"];
            var CaNgay = c.Request["CaNgay"];
            var NgayTao = c.Request["NgayTao"];
            var NguoiTao = c.Request["NguoiTao"];
            var NgayCapNhat = c.Request["NgayCapNhat"];
            var NguoiCapNhat = c.Request["NguoiCapNhat"];
            var BoQua = c.Request["BoQua"];
            var Xoa = c.Request["Xoa"];
            #endregion

            switch (subAct)
            {
                case "get":
                    #region Nạp js
                        sb.Append(JavaScriptConvert.SerializeObject(SuKienDal.SelectUnXoa(con, Xoa, "100")));
                    break;
                    #endregion
                case "draff":
                    #region Nạp draff
                    sb.Append(Guid.NewGuid().ToString());
                    break;
                    #endregion
                case "save":
                    #region save
                    if (!string.IsNullOrEmpty(Ten))
                    {
                        var item = new SuKien();
                        if (!string.IsNullOrEmpty(ID))
                        {
                            item = SuKienDal.SelectById(new Guid(ID));
                        }
                        item.NgayBatDau = Convert.ToDateTime(string.Format("{0} {1}",Ngay, Gio) , new CultureInfo("vi-Vn"));
                        item.NgayCapNhat = DateTime.Now;
                        item.MoTa = MoTa;
                        item.NguoiCapNhat = Security.Username;
                        item.NhanVien = NhanVien;
                        item.Ten = Ten;
                        if (!string.IsNullOrEmpty(DM_ID))
                        {
                            item.DM_ID = new Guid(DM_ID);
                        }
                        if (!string.IsNullOrEmpty(KH_ID))
                        {
                            item.KH_ID = new Guid(KH_ID);
                        }
                        if (!string.IsNullOrEmpty(ID))
                        {
                            item = SuKienDal.Update(item);
                        }
                        else
                        {
                            item.ID = Guid.NewGuid();
                            item.NgayTao = DateTime.Now;
                            item.NguoiTao = Security.Username;
                            item = SuKienDal.Insert(item);
                        }
                        sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(item));
                    }
                    break;
                    #endregion
                case "del":
                    #region save
                    if (Security.IsAuthenticated())
                    {
                        SuKienDal.DeleteById(new Guid(ID));
                    }
                    break;
                    #endregion
                case "edit":
                    #region edit
                    sb.AppendFormat("({0})", JavaScriptConvert.SerializeObject(SuKienDal.SelectById(new Guid(ID))));
                    break;
                    #endregion
                case "getGio":
                    #region Nạp Gio
                    var listGio = new List<string>();
                    for (int i = 8; i < 19; i++)
                    {
                        for (int j = 0; j < 60; j += 20)
                        {
                            listGio.Add(string.Format("{0}:{1}", i.ToString().Length == 1 ? string.Format("0{0}", i) : i.ToString(), j.ToString().Length == 1 ? string.Format("0{0}", j) : j.ToString()));
                        }
                    }
                    sb.Append(JavaScriptConvert.SerializeObject(listGio));
                    break;
                    #endregion
                case "scpt":
                    #region Nạp js
                    sb.AppendFormat(@"{0}"
                        , cs.GetWebResourceUrl(typeof(DanhSach), "appStore.pmSpa.desktop.controls.SuKienMgr.SuKien.js"));
                    break;
                    #endregion
                default:
                    #region nạp
                    var mdlFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "SuKienMgr.mdl.htm");
                    var itemFormat = Lib.GetResource(Assembly.GetExecutingAssembly(), "SuKienMgr.su-kien-item.htm");
                    var sbItem = new StringBuilder();
                    foreach (var sk in SuKienDal.SelectUnXoa(con, Xoa, "100"))
                    {
                        sbItem.AppendFormat(itemFormat
                            , sk.ID
                            , sk.NgayBatDau.ToString("hh:mm dd/MM/yyyy")
                            , sk.Ten
                            , sk.MoTa
                            , sk.NhanVien_Ten
                            , sk.KH_Ten);
                    }
                    sb.Append(string.Format(mdlFormat, sbItem));
                    sb.Append(Lib.GetResource(Assembly.GetExecutingAssembly(), "SuKienMgr.su-kien-item-tmpl.htm"));
                    sb.AppendFormat(@"<script>$.getScript('{0}',function(){1});</script>"
                        , cs.GetWebResourceUrl(typeof(DanhSach), "appStore.pmSpa.desktop.controls.SuKienMgr.SuKienAll.js")
                        , "{SuKienAllFn.init();}");
                    break;
                    #endregion
            }

            Html = sb.ToString();
            base.KhoiTao(con);
        }