public void Danhsach_Datbao() { string where = " 1=1 "; if (!String.IsNullOrEmpty(this.txtTen_Khachhang.Text.Trim())) { where += " AND " + string.Format(" Ten_KhachHang like N'%{0}%'", UltilFunc.SqlFormatText(this.txtTen_Khachhang.Text.Trim())); } if (ddl_Anpham.SelectedIndex > 0) { where += " AND Ma_anpham =" + ddl_Anpham.SelectedValue.ToString(); } pages.PageSize = Global.MembersPerPage; DatbaoDAL _datbaoDAL = new DatbaoDAL(); DataSet _ds; _ds = _datbaoDAL.BindGridT_Datbao(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 = _datbaoDAL.BindGridT_Datbao(pages.PageIndex - 1, pages.PageSize, where); } grdList.DataSource = _ds; grdList.DataBind(); _ds.Clear(); pages.TotalRecords = curentPages.TotalRecords = TotalRecords; curentPages.TotalPages = pages.CalculateTotalPages(); curentPages.PageIndex = pages.PageIndex; Session["PageIndex"] = pages.PageIndex; }
private void GetItem(int _id) { T_Datbao _obj = new T_Datbao(); DatbaoDAL _objDAL = new DatbaoDAL(); _obj = _objDAL.GetOneFromT_DatbaoByID(_id); this.ddl_TenKH.SelectedIndex = UltilFunc.GetIndexControl(ddl_TenKH, _obj.Ma_khachhang.ToString()); // this.txt_SoHD.Text = _obj.Hopdong_so; UltilFunc.BindCombox(ddl_SoHD, "ID", "hopdongso", "T_Hopdong", " Ma_KhachHang = " + _obj.Ma_khachhang.ToString()); this.ddl_SoHD.SelectedIndex = UltilFunc.GetIndexControl(ddl_SoHD, _obj.Hopdong_so); this.ddl_Anpham.SelectedIndex = UltilFunc.GetIndexControl(ddl_Anpham, _obj.Ma_anpham.ToString()); this.txt_Sotien.Text = _obj.Sotien.ToString(); this.txt_Soluong.Text = _obj.Soluong.ToString(); this.txt_NgayBatDau.Text = _obj.NGAY_BATDAU.ToString("dd/MM/yyyy"); this.txt_NgayKetThuc.Text = _obj.NGAY_KETTHUC.ToString("dd/MM/yyyy"); this.txt_Ghichu.Text = _obj.Ghichu; }
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; } DatbaoDAL _datbaoDAL = new DatbaoDAL(); T_Datbao _datbao = SetItem(); int menuID = 0; if (Request["ID"] != null && Request["ID"].ToString() != "" && Request["ID"].ToString() != String.Empty) { menuID = int.Parse(Request["ID"].ToString()); } int _return = _datbaoDAL.InsertT_Datbao(_datbao); if (Page.Request.Params["id"] == null) { action.Thaotac = "[Thêm mới T_Datbao]-->[Mã:" + _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(); BindCombo(); return; } if (Page.Request.Params["id"] != null) { action.Thaotac = "[Sửa T_Datbao]-->[Mã :" + 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(); BindCombo(); return; } }
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 DatbaoDAL objDAL = new DatbaoDAL(); if (e.CommandArgument.ToString().ToLower() == "edit") { int _ID = Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString()); Response.Redirect("~/Phathanh/DatbaoEdit.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + _ID); } if (e.CommandArgument.ToString().ToLower() == "delete") { objDAL.DeleteOneFromT_Datbao(Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString())); action.Thaotac = "[Xóa T_Datbao]-->[Thao tác Xóa Trong Bảng T_Datbao][ID:" + this.grdList.DataKeys[e.Item.ItemIndex].ToString() + " ]"; this.Danhsach_Datbao(); } }