예제 #1
0
 public List <string> AutoCompleteMaDT(string MaDT)
 {
     try
     {
         List <string> result = new List <string>();
         DoituongDAL   _DAL   = new DoituongDAL();
         DataSet       _ds;
         _ds = _DAL.Select_MaDoiTuong(MaDT);
         DataTable dt = _ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow item in dt.Rows)
             {
                 result.Add(item["Ma_Doituong"].ToString());
             }
         }
         else
         {
             result.Add("Mã đối tượng này chưa tồn tại !!");
         }
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #2
0
 public List <string> AutoCompleteStt(string Stt)
 {
     try
     {
         List <string> result = new List <string>();
         DoituongDAL   _DAL   = new DoituongDAL();
         DataSet       _ds;
         _ds = _DAL.Select_TenDoiTuong_By_Stt(Stt);
         DataTable dt = _ds.Tables[0];
         if (dt.Rows.Count > 0)
         {
             foreach (DataRow item in dt.Rows)
             {
                 result.Add(item["Ten_Doituong"].ToString());
             }
         }
         else
         {
             result.Add("Số thứ tự này chưa tồn tại !!");
         }
         return(result);
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #3
0
        protected void GVDoituong_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(GVDoituong.DataKeys[e.RowIndex].Values["ID"].ToString());
            DoituongDAL _dtDAL = new DoituongDAL();
            if (_dtDAL.CheckExists_Madoituong(_id, 1) == 1)
            {
                return;
            }
            else
            {
                _dtDAL.DeleteOneFromT_Doituong(_id);
                action.Thaotac = "[Xóa đối tượng]-->[Mã đối tượng:" + _id.ToString() + " ]";
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
            }
            BindList_Doituong();
        }
예제 #4
0
        protected void GVDoituong_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(GVDoituong.DataKeys[e.RowIndex].Values["ID"].ToString());
            DoituongDAL _dtDAL = new DoituongDAL();
            if (_dtDAL.CheckExists_Madoituong(_id, 1) == 1)
            {
                return;
            }
            else
            {
                _dtDAL.DeleteOneFromT_Doituong(_id);
                lblMessError.Text = "";
                action.Thaotac    = "[Xóa đối tượng]-->[Mã đối tượng:" + _id.ToString() + " ]";
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
            }
            BindList_Doituong();
            BinQuytrinhtheoAnPham();

            UltilFunc.RunJavaScriptCode("$.fx.speeds._default = 10; var dlg = jQuery('#dialog').dialog({draggable: true,  resizable: true, hide: 'scale', modal: true, width: 500 }); dlg.parent().appendTo(jQuery('form:first'));");
        }
예제 #5
0
        protected void GVDoituong_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 _ma          = (TextBox)GVDoituong.FooterRow.FindControl("txt_MaDoituong");
                TextBox _ten         = (TextBox)GVDoituong.FooterRow.FindControl("txt_Tendoituong");
                TextBox _englishname = (TextBox)GVDoituong.FooterRow.FindControl("txt_EnglishName");
                TextBox _stt         = (TextBox)GVDoituong.FooterRow.FindControl("txt_STT");
                //Label _MaDT = (Label)GVDoituong.FooterRow.FindControl("lblMaDT_Error");
                //Label _STT = (Label)GVDoituong.FooterRow.FindControl("lblSTT_Error");
                int         _return;
                DoituongDAL _doituongDAL = new DoituongDAL();
                if (_doituongDAL.Check_Madoituong(0, _ma.Text.Trim()) > 0)
                {
                    lblMessError.Text     = "Mã đối tượng đã tồn tại";
                    GVDoituong.ShowFooter = true;
                    BindList_Doituong();
                }
                else if (_doituongDAL.Check_STT(0, Convert.ToInt32(_stt.Text.Trim())) > 0)
                {
                    lblMessError.Text     = "Số thứ tự đã tồn tại";
                    GVDoituong.ShowFooter = true;
                    BindList_Doituong();
                }
                else
                {
                    _dt              = new T_Doituong();
                    _dt.ID           = 0;
                    _dt.Ma_Doituong  = _ma.Text.Trim();
                    _dt.Ten_Doituong = _ten.Text.Trim();
                    _dt.EnglishName  = _englishname.Text.Trim();
                    if (!String.IsNullOrEmpty(_stt.Text.Trim()))
                    {
                        _dt.STT = Convert.ToInt32(_stt.Text.Trim());
                    }

                    _dt.Ngaysua    = DateTime.Now;
                    _dt.Nguoitao   = _user.UserID;
                    _dt.Ngaytao    = DateTime.Now;
                    _dt.Nguoisua   = _user.UserID;
                    _return        = _doituongDAL.InsertT_Doituong(_dt);
                    action.Thaotac = "[Thêm mới đối tượng]-->[Mã mã đối tượng:" + _return.ToString() + " ]";
                    actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                    BindList_Doituong();
                }
            }
        }
예제 #6
0
        protected void GVDoituong_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(GVDoituong.DataKeys[e.RowIndex].Value.ToString());

            TextBox     _ma          = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_MaDoituong");
            TextBox     _ten         = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_Tendoituong");
            TextBox     _englishname = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_EnglishName");
            TextBox     _stt         = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_STT");
            Label       _MaDT        = (Label)GVDoituong.Rows[e.RowIndex].FindControl("lblMaDT_Error");
            Label       _STT         = (Label)GVDoituong.Rows[e.RowIndex].FindControl("lblSTT_Error");
            DoituongDAL _dtDAL       = new DoituongDAL();
            if (_dtDAL.Check_Madoituong(_id, _ma.Text.Trim()) > 0)
            {
                _MaDT.Text = "Mã đối tượng đã tồn tại";
                return;
            }
            else if (_dtDAL.Check_STT(_id, Convert.ToInt32(_stt.Text.Trim())) > 0)
            {
                _STT.Text = "Số thứ tự đã tồn tại";
                return;
            }
            else
            {
                _dt              = new T_Doituong();
                _dt.ID           = _id;
                _dt.Ma_Doituong  = _ma.Text.Trim();
                _dt.Ten_Doituong = _ten.Text.Trim();
                _dt.EnglishName  = _englishname.Text.Trim();
                if (!String.IsNullOrEmpty(_stt.Text.Trim()))
                {
                    _dt.STT = Convert.ToInt32(_stt.Text.Trim());
                }

                _dt.Ngaysua  = DateTime.Now;
                _dt.Nguoitao = _user.UserID;
                _dt.Ngaytao  = DateTime.Now;
                _dt.Nguoisua = _user.UserID;
                _return      = _dtDAL.InsertT_Doituong(_dt);

                action.Thaotac = "[Sửa đối tượng]-->[Mã đối tượng:" + _return.ToString() + " ]";
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);

                GVDoituong.EditIndex = -1;
                BindList_Doituong();
            }
        }
예제 #7
0
        protected void GVDoituong_OnRowCommand(object source, GridViewCommandEventArgs e)
        {
            HPCBusinessLogic.Lichsu_Thaotac_HethongDAL actionDAL = new Lichsu_Thaotac_HethongDAL();
            T_Lichsu_Thaotac_Hethong action = new T_Lichsu_Thaotac_Hethong();

            if (e.CommandName.Equals("AddNew"))
            {
                TextBox     _ma  = (TextBox)GVDoituong.FooterRow.FindControl("txt_MaDoituong");
                TextBox     _ten = (TextBox)GVDoituong.FooterRow.FindControl("txt_Tendoituong");
                TextBox     _stt = (TextBox)GVDoituong.FooterRow.FindControl("txt_STT");
                int         _return;
                DoituongDAL _doituongDAL = new DoituongDAL();
                if (_doituongDAL.Check_Madoituong(0, _ma.Text.Trim()) > 0)
                {
                    lblMessError.Text     = "Mã đối tượng đã tồn tại";
                    GVDoituong.ShowFooter = true;
                    BindList_Doituong();
                }
                else if (_doituongDAL.Check_STT(0, Convert.ToInt32(_stt.Text.Trim())) > 0)
                {
                    lblMessError.Text     = "Số thứ tự đã tồn tại";
                    GVDoituong.ShowFooter = true;
                    BindList_Doituong();
                }
                else
                {
                    _dt              = new T_Doituong();
                    _dt.ID           = 0;
                    _dt.Ma_Doituong  = _ma.Text.Trim();
                    _dt.Ten_Doituong = _ten.Text.Trim();
                    if (!String.IsNullOrEmpty(_stt.Text.Trim()))
                    {
                        _dt.STT = Convert.ToInt32(_stt.Text.Trim());
                    }

                    _dt.Ngaysua    = DateTime.Now;
                    _dt.Nguoitao   = _user.UserID;
                    _dt.Ngaytao    = DateTime.Now;
                    _dt.Nguoisua   = _user.UserID;
                    _return        = _doituongDAL.InsertT_Doituong(_dt);
                    action.Thaotac = "[Thêm mới đối tượng]-->[Mã mã đối tượng:" + _return.ToString() + " ]";
                    actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                    lblMessError.Text = "";
                    BindList_Doituong();
                    BinQuytrinhtheoAnPham();
                }

                UltilFunc.RunJavaScriptCode("$.fx.speeds._default = 10; var dlg = jQuery('#dialog').dialog({draggable: true,  resizable: true, hide: 'scale', modal: true, width: 500 }); dlg.parent().appendTo(jQuery('form:first'));");
            }
        }
예제 #8
0
        public void BindList_Doituong()
        {
            string where = " 1=1 ";

            DoituongDAL _DAL = new DoituongDAL();
            DataSet     _ds;

            pages.PageSize = 10;//Global.MembersPerPage;
            _ds            = _DAL.BindGridT_Doituong(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_Doituong(pages.PageIndex - 1, pages.PageSize, where);
            }
            if (_ds.Tables[0].Rows.Count > 0)
            {
                DataView _dv = _ds.Tables[0].DefaultView;
                if (SortExtension.Length > 1)
                {
                    _dv.Sort = SortExtension + " " + SortOrder;
                }
                GVDoituong.DataSource = _dv;
                GVDoituong.DataBind();
                GVDoituong.ShowFooter = false;
            }
            else
            {
                _ds.Tables[0].Rows.Add(_ds.Tables[0].NewRow());
                GVDoituong.DataSource = _ds;
                GVDoituong.DataBind();
                int columncount = GVDoituong.Rows[0].Cells.Count;
                GVDoituong.Rows[0].Cells.Clear();
                GVDoituong.Rows[0].Cells.Add(new TableCell());
                GVDoituong.Rows[0].Cells[0].ColumnSpan = columncount;
                GVDoituong.Rows[0].Cells[0].Text       = "Không có bản ghi nào";
                GVDoituong.ShowFooter = false;
            }
            pages.TotalRecords     = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages = pages.CalculateTotalPages();
            curentPages.PageIndex  = pages.PageIndex;
            Session["CurrentPage"] = pages.PageIndex;
        }
예제 #9
0
        protected void GVDoituong_OnRowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                ImageButton btnDelete = (ImageButton)e.Row.FindControl("btnDelete");
                ImageButton btnAdd    = (ImageButton)e.Row.FindControl("btnAdd");
                if (btnAdd != null)
                {
                    if (!_Role.R_Write)
                    {
                        btnAdd.Enabled = _Role.R_Write;
                    }
                }
                if (btnDelete != null)
                {
                    if (!_Role.R_Delete)
                    {
                        btnDelete.Enabled = _Role.R_Delete;
                    }
                    else
                    {
                        btnDelete.Attributes.Add("onclick", "return confirm('Bạn có chắc chắn muốn xóa?');");
                    }
                    DoituongDAL _dtDAL = new DoituongDAL();
                    int         _id    = Convert.ToInt32(GVDoituong.DataKeys[e.Row.RowIndex].Value);
                    if (_dtDAL.CheckExists_Madoituong(_id, 1) == 1)
                    {
                        btnDelete.Attributes.Add("onclick", "return alert(\"Đối tượng này đang được sử dụng\");");
                    }
                    else
                    {
                        btnDelete.Attributes.Add("onclick", "return confirm(\"Bạn có chắc chắn muốn xóa không?\");");
                    }
                }
                Label lblSTT = (Label)e.Row.FindControl("lblSTT");
                if (lblSTT != null)
                {
                    lblSTT.Text = (pages.PageIndex * pages.PageSize + e.Row.RowIndex + 1).ToString();
                }

                e.Row.Attributes.Add("onmouseover", "currColor=this.style.backgroundColor;this.style.backgroundColor='" + CommonLib.HPCOnmouseoverGrid() + "'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currColor");
            }
        }
예제 #10
0
        public void BindList_Doituong()
        {
            string where = " T_Doituong.Ma_Doituong not in (select T_Doituong_Anpham.Ma_Doituong from T_Doituong_Anpham where T_Doituong_Anpham.Ma_AnPham = " + maanpham + ") ";

            DoituongDAL _DAL = new DoituongDAL();
            DataSet     _ds;

            pages.PageSize = Global.MembersPerPage;
            _ds            = _DAL.BindGridT_Doituong(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_Doituong(pages.PageIndex - 1, pages.PageSize, where);
            }
            if (_ds.Tables[0].Rows.Count > 0)
            {
                DataView _dv = _ds.Tables[0].DefaultView;
                GVDoituong.DataSource = _dv;
                GVDoituong.DataBind();
                GVDoituong.ShowFooter = false;
            }
            else
            {
                _ds.Tables[0].Rows.Add(_ds.Tables[0].NewRow());
                GVDoituong.DataSource = _ds;
                GVDoituong.DataBind();
                int columncount = GVDoituong.Rows[0].Cells.Count;
                GVDoituong.Rows[0].Cells.Clear();
                GVDoituong.Rows[0].Cells.Add(new TableCell());
                GVDoituong.Rows[0].Cells[0].ColumnSpan = columncount;
                GVDoituong.Rows[0].Cells[0].Text       = "Không có bản ghi nào";
                GVDoituong.ShowFooter = false;
            }
            pages.TotalRecords     = curentPages.TotalRecords = TotalRecords;
            curentPages.TotalPages = pages.CalculateTotalPages();
            curentPages.PageIndex  = pages.PageIndex;
            Session["CurrentPage"] = pages.PageIndex;
        }
예제 #11
0
        protected void GVDoituong_RowUpdating(object source, 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(GVDoituong.DataKeys[e.RowIndex].Value.ToString());

            TextBox     txtMaDT  = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_MaDoituong");
            TextBox     txtTenDT = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_Tendoituong");
            TextBox     txtSTT   = (TextBox)GVDoituong.Rows[e.RowIndex].FindControl("txt_STT");
            Label       _MaDT    = (Label)GVDoituong.Rows[e.RowIndex].FindControl("lblMaDT_Error");
            Label       _STT     = (Label)GVDoituong.Rows[e.RowIndex].FindControl("lblSTT_Error");
            DoituongDAL _dtDAL   = new DoituongDAL();
            try
            {
                int.Parse(txtSTT.Text);
            }
            catch (Exception)
            {
                lblMessError.Text = "Nhập lại số thứ tự";
                throw;
            }
            if (_dtDAL.Check_Madoituong(_id, txtMaDT.Text.Trim()) > 0)
            {
                _MaDT.Text = "Mã đối tượng đã tồn tại";
                return;
            }
            else if (_dtDAL.Check_STT(_id, Convert.ToInt32(txtSTT.Text.Trim())) > 0)
            {
                _STT.Text = "Số thứ tự đã tồn tại";
                return;
            }
            else
            {
                _dt              = new T_Doituong();
                _dt.ID           = _id;
                _dt.Ma_Doituong  = txtMaDT.Text.Trim();
                _dt.Ten_Doituong = txtTenDT.Text.Trim();
                if (!String.IsNullOrEmpty(txtSTT.Text.Trim()))
                {
                    _dt.STT = Convert.ToInt32(txtSTT.Text.Trim());
                }

                _dt.Ngaysua  = DateTime.Now;
                _dt.Nguoitao = _user.UserID;
                _dt.Ngaytao  = DateTime.Now;
                _dt.Nguoisua = _user.UserID;
                _return      = _dtDAL.InsertT_Doituong(_dt);

                action.Thaotac = "[Sửa đối tượng]-->[Mã đối tượng:" + _return.ToString() + " ]";
                actionDAL.InserT_Lichsu_Thaotac_Hethong(action);
                lblMessError.Text    = "";
                GVDoituong.EditIndex = -1;
                BindList_Doituong();
                BinQuytrinhtheoAnPham();
            }

            UltilFunc.RunJavaScriptCode("$.fx.speeds._default = 10; var dlg = jQuery('#dialog').dialog({draggable: true,  resizable: true, hide: 'scale', modal: true, width: 500 }); dlg.parent().appendTo(jQuery('form:first'));");
        }