Exemplo n.º 1
0
        public void Danhsach_Khachhang()
        {
            string where = "  Loai_KH = 1 ";
            if (!String.IsNullOrEmpty(this.txtTen_Khachhang.Text.Trim()))
            {
                where += " " + string.Format(" Ten_KhachHang like N'%{0}%'", UltilFunc.SqlFormatText(this.txtTen_Khachhang.Text.Trim()));
            }

            pages.PageSize = Global.MembersPerPage;
            KhachhangDAL _khachhangDAL = new KhachhangDAL();
            DataSet      _ds;

            _ds = _khachhangDAL.BindGridT_Khachhang(pages.PageIndex, pages.PageSize, where);
            int TotalRecords = Convert.ToInt32(_ds.Tables[1].Rows[0].ItemArray[0].ToString());
            int TotalRecord  = Convert.ToInt32(_ds.Tables[0].Rows.Count);

            if (TotalRecord == 0)
            {
                _ds = _khachhangDAL.BindGridT_Khachhang(pages.PageIndex - 1, pages.PageSize, where);
            }
            grdList.DataSource = _ds.Tables[0];
            grdList.DataBind();
            _ds.Clear();
            pages.TotalRecords         = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages     = pages.CalculateTotalPages();
            curentPages.PageIndex      = pages.PageIndex;
            Session["PageIndex"]       = pages.PageIndex;
            grdList.Columns[6].Visible = IsRoleDelete();
        }
Exemplo n.º 2
0
        public void grdList_EditCommand(object source, DataGridCommandEventArgs e)
        {
            #region GhiLog
            Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
            T_Lichsu_Thaotac_Hethong  action    = new T_Lichsu_Thaotac_Hethong();
            action.Ma_Nguoidung = _user.UserID;
            action.TenDaydu     = _user.UserFullName;
            action.HostIP       = IpAddress();
            action.NgayThaotac  = DateTime.Now;
            #endregion
            KhachhangDAL objDAL = new KhachhangDAL();
            if (e.CommandArgument.ToString().ToLower() == "edit")
            {
                int cusID = Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString());
                Response.Redirect("~/Phathanh/KhachHangEdit.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + cusID);
            }
            if (e.CommandArgument.ToString().ToLower() == "delete")
            {
                bool _bool;
                _bool = IsCustomerExsits(Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString()));
                if (_bool == false)
                {
                    objDAL.DeleteOneFromT_KhachHang(Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString()));
                    action.Thaotac = "[Xóa T_KhachHang]-->[Thao tác Xóa Trong Bảng T_KhachHang][ID:" + this.grdList.DataKeys[e.Item.ItemIndex].ToString() + " ]";
                    this.Danhsach_Khachhang();
                }
                else
                {
                    return;
                }
            }
            //if (e.CommandArgument.ToString().ToLower() == "sort")
            //{
            //    if (this.ViewState["SortExp"] == null)
            //    {
            //        this.ViewState["SortExp"] = e.CommandArgument.ToString();
            //        this.ViewState["SortOrder"] = "ASC";
            //    }
            //    else
            //    {
            //        if (this.ViewState["SortExp"].ToString() == e.CommandArgument.ToString())
            //        {
            //            if (this.ViewState["SortOrder"].ToString() == "ASC")
            //                this.ViewState["SortOrder"] = "DESC";
            //            else
            //                this.ViewState["SortOrder"] = "ASC";
            //        }
            //        else
            //        {
            //            this.ViewState["SortOrder"] = "ASC";
            //            this.ViewState["SortExp"] = e.CommandArgument.ToString();
            //        }
            //    }

            Danhsach_Khachhang();
        }
Exemplo n.º 3
0
        protected string TenKhachHang(string _Id)
        {
            string       strReturn = "";
            T_KhachHang  _kh       = new T_KhachHang();
            KhachhangDAL _dal      = new KhachhangDAL();

            if (!String.IsNullOrEmpty(_Id) && Convert.ToInt32(_Id) > 0)
            {
                _kh       = _dal.GetOneFromT_KhachHangByID(Convert.ToInt32(_Id));
                strReturn = _kh.Ten_KhachHang;
            }
            else
            {
                strReturn = "";
            }
            return(strReturn);
        }
Exemplo n.º 4
0
        private void GetItem(int _id)
        {
            T_KhachHang  _obj    = new T_KhachHang();
            KhachhangDAL _objDAL = new KhachhangDAL();

            _obj = _objDAL.GetOneFromT_KhachHangByID(_id);
            this.txt_TenKH.Text        = _obj.Ten_KhachHang;
            this.txt_Diachi.Text       = _obj.DiaChi;
            this.txt_Dienthoai.Text    = _obj.SoDienThoai;
            this.txt_Email.Text        = _obj.Email;
            this.txt_Fax.Text          = _obj.FAX;
            this.txt_Masothue.Text     = _obj.MaSoThue;
            this.txt_Mota.Text         = _obj.Ghichu;
            this.txt_Nguoidaidien.Text = _obj.NguoiDaiDien;
            this.txt_Taikhoan.Text     = _obj.TaiKhoan;
            this.txt_Tendaydu.Text     = _obj.Tendaydu;
        }
Exemplo n.º 5
0
        private void GetItem(int _id)
        {
            T_KhachHang  _obj    = new T_KhachHang();
            KhachhangDAL _objDAL = new KhachhangDAL();

            _obj = _objDAL.GetOneFromT_KhachHangByID(_id);
            this.txt_TenKH.Text        = _obj.Ten_KhachHang;
            this.txt_Diachi.Text       = _obj.DiaChi;
            this.txt_Dienthoai.Text    = _obj.SoDienThoai;
            this.txt_Email.Text        = _obj.Email;
            this.txt_Fax.Text          = _obj.FAX;
            this.txt_Masothue.Text     = _obj.MaSoThue;
            this.txt_Mota.Text         = _obj.Ghichu;
            this.txt_Nguoidaidien.Text = _obj.NguoiDaiDien;
            this.txt_Taikhoan.Text     = _obj.TaiKhoan;
            this.txt_Tendaydu.Text     = _obj.Tendaydu;
            //ddl_LoaiKH.SelectedIndex = UltilFunc.GetIndexControl(ddl_LoaiKH, _obj.Loai_KH.ToString());
        }
Exemplo n.º 6
0
        protected void Save_Click(object sender, EventArgs e)
        {
            #region GhiLog
            Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
            T_Lichsu_Thaotac_Hethong  action    = new T_Lichsu_Thaotac_Hethong();
            action.Ma_Nguoidung = _user.UserID;
            action.TenDaydu     = _user.UserFullName;
            action.HostIP       = IpAddress();
            action.NgayThaotac  = DateTime.Now;
            #endregion
            this.Page.Validate(vs_Themmoi.ValidationGroup);
            if (!Page.IsValid)
            {
                return;
            }
            KhachhangDAL _KhachHangDAL = new KhachhangDAL();
            T_KhachHang  _KhachHang    = SetItem();

            int menuID = 0;
            if (Request["ID"] != null && Request["ID"].ToString() != "" && Request["ID"].ToString() != String.Empty)
            {
                menuID = int.Parse(Request["ID"].ToString());
            }
            int _return = _KhachHangDAL.InsertT_Khachhang(_KhachHang);
            if (Page.Request.Params["id"] == null)
            {
                action.Thaotac = "[Thêm mới khách hàng]-->[mã khách hàng:" + _return.ToString() + " ]";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("VALIDATE_ADDNEWS") + "');", true);
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                Clear();
                return;
            }
            if (Page.Request.Params["id"] != null)
            {
                action.Thaotac = "[Sửa thông tin khách hàng]-->[Mã KH:" + Page.Request["id"].ToString() + " ]";
                System.Web.UI.ScriptManager.RegisterStartupScript(this, typeof(string), "Message", "alert('" + Global.RM.GetString("UpdateSuccessfully") + "');", true);
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                Clear();
                return;
            }
        }
Exemplo n.º 7
0
        protected void Save_Click(object sender, EventArgs e)
        {
            #region GhiLog
            Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
            T_Lichsu_Thaotac_Hethong  action    = new T_Lichsu_Thaotac_Hethong();
            action.Ma_Nguoidung = _user.UserID;
            action.TenDaydu     = _user.UserFullName;
            action.HostIP       = IpAddress();
            action.NgayThaotac  = DateTime.Now;
            #endregion
            this.Page.Validate(vs_Themmoi.ValidationGroup);
            if (!Page.IsValid)
            {
                return;
            }
            KhachhangDAL _KhachHangDAL = new KhachhangDAL();
            T_KhachHang  _KhachHang    = SetItem();

            int menuID = 0;
            if (Request["ID"] != null && Request["ID"].ToString() != "" && Request["ID"].ToString() != String.Empty)
            {
                menuID = int.Parse(Request["ID"].ToString());
            }
            int _return = _KhachHangDAL.InsertT_Khachhang(_KhachHang);
            if (Page.Request.Params["id"] == null)
            {
                action.Thaotac = "[Thêm mới khách hàng]-->[mã khách hàng:" + _return.ToString() + " ]";

                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                Clear();
                return;
            }
            if (Page.Request.Params["id"] != null)
            {
                action.Thaotac = "[Sửa thông tin khách hàng]-->[Mã KH:" + Page.Request["id"].ToString() + " ]";

                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                Clear();
                return;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            string prefixText = context.Request.QueryString["q"];

            StringBuilder sb   = new StringBuilder();
            KhachhangDAL  _DAL = new KhachhangDAL();
            DataSet       _ds;

            _ds = _DAL.Select_Loai_KhachHang(prefixText);
            //  sb.Append(string.Format("{0}|{1}", "Tên", "0")).Append(Environment.NewLine);
            if (_ds.Tables[0].Rows.Count > 0)
            {
                for (int _i = 0; _i < _ds.Tables[0].Rows.Count; _i++)
                {
                    sb.Append(string.Format("{0}|{1}", _ds.Tables[0].Rows[_i]["Ten_KhachHang"].ToString(), _ds.Tables[0].Rows[_i]["Ma_KhachHang"].ToString())).Append(Environment.NewLine);//(_ds.Tables[0].Rows[_i]["Ten_KhachHang"].ToString()).Append(Environment.NewLine);
                }
            }
            else
            {
                sb.Append(string.Format("{0}|{1}", "No records to display", "0")).Append(Environment.NewLine);//(_ds.Tables[0].Rows[_i]["Ten_KhachHang"].ToString()).Append(Environment.NewLine);
            }
            context.Response.Write(sb.ToString());
        }
Exemplo n.º 9
0
 public void grdList_EditCommand(object source, DataGridCommandEventArgs e)
 {
     #region GhiLog
     Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
     T_Lichsu_Thaotac_Hethong  action    = new T_Lichsu_Thaotac_Hethong();
     action.Ma_Nguoidung = _user.UserID;
     action.TenDaydu     = _user.UserFullName;
     action.HostIP       = IpAddress();
     action.NgayThaotac  = DateTime.Now;
     #endregion
     KhachhangDAL objDAL = new KhachhangDAL();
     if (e.CommandArgument.ToString().ToLower() == "edit")
     {
         int cusID = Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString());
         Response.Redirect("~/Danhmuc/EditKhachHang.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + cusID);
     }
     if (e.CommandArgument.ToString().ToLower() == "delete")
     {
         objDAL.DeleteOneFromT_KhachHang(Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString()));
         action.Thaotac = "[Xóa T_KhachHang]-->[Thao tác Xóa Trong Bảng T_KhachHang][ID:" + this.grdList.DataKeys[e.Item.ItemIndex].ToString() + " ]";
         this.Danhsach_Khachhang();
     }
 }