Ejemplo n.º 1
0
        public void ChiTiet_PhatHanh()
        {
            string where = " 1=1 ";
            if (ddl_Anpham.SelectedIndex > 0)
            {
                where += " AND Ma_Anpham =" + ddl_Anpham.SelectedValue.ToString();
            }
            if (ddl_Sobao.SelectedIndex > 0)
            {
                where += " AND Ma_Sobao =" + ddl_Sobao.SelectedValue.ToString();
            }
            //if (!String.IsNullOrEmpty(this.txtTen_Khachhang.Text.Trim()))
            //    where += " AND " + string.Format(" Ten_KhachHang like N'%{0}%'", UltilFunc.SqlFormatText(this.txtTen_Khachhang.Text.Trim()));

            pages.PageSize = Global.MembersPerPage;
            PhathanhDAL _phathanhDAL = new PhathanhDAL();
            DataSet     _ds;

            _ds = _phathanhDAL.BindGridT_Phathanh(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 = _phathanhDAL.BindGridT_Phathanh(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;
        }
        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;
            }
            PhathanhDAL _phathanhDAL = new PhathanhDAL();
            T_Phathanh  _phathanh    = SetItem();

            int menuID = 0;
            if (Request["ID"] != null && Request["ID"].ToString() != "" && Request["ID"].ToString() != String.Empty)
            {
                menuID = int.Parse(Request["ID"].ToString());
            }
            int _return = _phathanhDAL.InsertT_Phathanh(_phathanh);
            if (Page.Request.Params["id"] == null)
            {
                action.Thaotac = "[Thêm mới T_PhatHanh]-->[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_PhatHanh]-->[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;
            }
        }
        private void GetItem(int _id)
        {
            T_Phathanh  _obj    = new T_Phathanh();
            PhathanhDAL _objDAL = new PhathanhDAL();

            _obj = _objDAL.GetOneFromT_PhathanhByID(_id);
            this.ddl_AnPham.SelectedIndex = UltilFunc.GetIndexControl(ddl_AnPham, _obj.Ma_Anpham.ToString());

            if (_id > 0)
            {
                this.ddl_Sobao.Items.Clear();
                UltilFunc.BindCombox(ddl_Sobao, "Ma_Sobao", "Ten_Sobao", "T_Sobao", " Ma_AnPham = " + _obj.Ma_Anpham.ToString());
                this.ddl_Sobao.SelectedIndex = UltilFunc.GetIndexControl(ddl_Sobao, _obj.Ma_Sobao.ToString());
                this.txt_NgayPhatHanh.Text   = _obj.Ngay_Phathanh.ToString("dd/MM/yyyy");
            }
            this.txt_SoluongPH.Text  = _obj.Soluong_PH.ToString();
            this.txt_SoluongTon.Text = _obj.Soluong_ton.ToString();
            this.txt_Ghichu.Text     = _obj.Ghichu;
        }
Ejemplo n.º 4
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
     PhathanhDAL objDAL = new PhathanhDAL();
     if (e.CommandArgument.ToString().ToLower() == "edit")
     {
         int _ID = Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString());
         Response.Redirect("~/Phathanh/ChiTiet_PhatHanh_Edit.aspx?Menu_ID=" + Page.Request["Menu_ID"].ToString() + "&ID=" + _ID);
     }
     if (e.CommandArgument.ToString().ToLower() == "delete")
     {
         objDAL.DeleteOneFromT_Phathanh(Convert.ToInt32(this.grdList.DataKeys[e.Item.ItemIndex].ToString()));
         action.Thaotac = "[Xóa T_PhatHanh]-->[Thao tác Xóa Trong Bảng T_PhatHanh][ID:" + this.grdList.DataKeys[e.Item.ItemIndex].ToString() + " ]";
         this.ChiTiet_PhatHanh();
     }
 }