protected void GVKichthuoc_RowUpdating(object sender, GridViewUpdateEventArgs 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 int _return; int _id = Convert.ToInt32(GVKichthuoc.DataKeys[e.RowIndex].Value.ToString()); TextBox _ten = (TextBox)GVKichthuoc.Rows[e.RowIndex].FindControl("txt_Kichthuoc"); TextBox _mota = (TextBox)GVKichthuoc.Rows[e.RowIndex].FindControl("txt_mota"); DropDownList _ddlAnpham = (DropDownList)GVKichthuoc.Rows[e.RowIndex].FindControl("ddl_AnPham"); KichthuocDAL _ktDAL = new KichthuocDAL(); _kt = new T_Kichthuoc(); _kt.Ma_Kichthuoc = _id; _kt.Ten_Kichthuoc = _ten.Text.Trim(); _kt.Mota = _mota.Text.Trim(); if (Convert.ToInt32(_ddlAnpham.SelectedValue.ToString()) > 0) { _kt.Ma_Anpham = Convert.ToInt32(_ddlAnpham.SelectedValue.ToString()); } else { _kt.Ma_Anpham = 0; } _kt.Ngaysua = DateTime.Now; _kt.Nguoitao = _user.UserID; _kt.Ngaytao = DateTime.Now; _kt.Nguoisua = _user.UserID; _return = _ktDAL.InsertT_Kichthuoc(_kt); action.Thaotac = "[Sửa kích thước]-->[Mã kích thước:" + _return.ToString() + " ]"; actionDAL.InserT_Lichsu_Thaotac_Hethong(action); GVKichthuoc.EditIndex = -1; BindList_Kichthuoc(); }
protected void GVKichthuoc_RowDeleting(object sender, GridViewDeleteEventArgs 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 int _id = Convert.ToInt32(GVKichthuoc.DataKeys[e.RowIndex].Values["Ma_Kichthuoc"].ToString()); KichthuocDAL _ktDAL = new KichthuocDAL(); _ktDAL.DeleteOneFromT_Kichthuoc(_id); action.Thaotac = "[Xóa kích thước]-->[Mã kích thước:" + _id.ToString() + " ]"; actionDAL.InserT_Lichsu_Thaotac_Hethong(action); BindList_Kichthuoc(); }
public void BindList_Kichthuoc() { string where = " 1=1 "; KichthuocDAL _DAL = new KichthuocDAL(); DataSet _ds; pages.PageSize = Global.MembersPerPage; _ds = _DAL.BindGridT_Kichthuoc(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 = _DAL.BindGridT_Kichthuoc(pages.PageIndex - 1, pages.PageSize, where); } if (_ds.Tables[0].Rows.Count > 0) { GVKichthuoc.DataSource = _ds; GVKichthuoc.DataBind(); GVKichthuoc.ShowFooter = false; } else { _ds.Tables[0].Rows.Add(_ds.Tables[0].NewRow()); GVKichthuoc.DataSource = _ds; GVKichthuoc.DataBind(); int columncount = GVKichthuoc.Rows[0].Cells.Count; GVKichthuoc.Rows[0].Cells.Clear(); GVKichthuoc.Rows[0].Cells.Add(new TableCell()); GVKichthuoc.Rows[0].Cells[0].ColumnSpan = columncount; GVKichthuoc.Rows[0].Cells[0].Text = "Không có bản ghi nào"; GVKichthuoc.ShowFooter = false; } pages.TotalRecords = curentPages.TotalRecords = TotalRecords; curentPages.TotalPages = pages.CalculateTotalPages(); curentPages.PageIndex = pages.PageIndex; Session["CurrentPage"] = pages.PageIndex; }
protected void GVKichthuoc_OnRowCommand1(object sender, GridViewCommandEventArgs 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 if (e.CommandName.Equals("AddNew")) { TextBox _ten = (TextBox)GVKichthuoc.FooterRow.FindControl("txt_Kichthuoc"); TextBox _mota = (TextBox)GVKichthuoc.FooterRow.FindControl("txt_mota"); DropDownList _ddlAnpham = (DropDownList)GVKichthuoc.FooterRow.FindControl("ddl_AnPham"); int _return; KichthuocDAL _kichthuocDAL = new KichthuocDAL(); _kt = new T_Kichthuoc(); _kt.Ma_Kichthuoc = 0; _kt.Ten_Kichthuoc = _ten.Text.Trim(); _kt.Mota = _mota.Text.Trim(); if (Convert.ToInt32(_ddlAnpham.SelectedValue.ToString()) > 0) { _kt.Ma_Anpham = Convert.ToInt32(_ddlAnpham.SelectedValue.ToString()); } else { _kt.Ma_Anpham = 0; } _kt.Ngaysua = DateTime.Now; _kt.Nguoitao = _user.UserID; _kt.Ngaytao = DateTime.Now; _kt.Nguoisua = _user.UserID; _return = _kichthuocDAL.InsertT_Kichthuoc(_kt); action.Thaotac = "[Thêm mới kích thước]-->[Mã kích thước:" + _return.ToString() + " ]"; actionDAL.InserT_Lichsu_Thaotac_Hethong(action); BindList_Kichthuoc(); } }