Ejemplo n.º 1
0
        protected void cmdView_Click1(object sender, ImageClickEventArgs e)
        {
            txtPageNumber.Text = "1";
            int       nPageNumber = int.Parse(txtPageNumber.Text);
            int       nPageSize   = int.Parse(txtPageSize.Text);
            DateTime  dtfrom      = DateTime.ParseExact(txtfromDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DateTime  dtto        = DateTime.ParseExact(txttoDatetime.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            DataTable nTable      = PostharvestHandling_Data.GetList(dtfrom, dtto, Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue.ToInt());

            if (nTable.Rows.Count == 0)
            {
                nTable.Rows.Add("", 0, 0, 0, "", null);
            }
            GV_PostharvestHandling.DataSource = nTable;
            GV_PostharvestHandling.DataBind();
            LoadPages();
        }
Ejemplo n.º 2
0
        public void LoadData()
        {
            //LoadDataToToolboxWeb.DropDown_DDL(DDLSeeds, "Select SeedsKey,SeedsName from PUL_Seeds where SeedsKey IN (Select SeedsKey FROM PUL_PostharvestHandling WHERE MemberKey = " + Convert.ToInt16(Session["EmployeeKey"]) + ")", false);
            int       nPageNumber = int.Parse(txtPageNumber.Text);
            int       nPageSize   = int.Parse(txtPageSize.Text);
            DataTable nTable      = PostharvestHandling_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue.ToInt());

            GV_PostharvestHandling.DataSource = nTable;
            if (nTable.Rows.Count == 0)
            {
                nTable.Rows.Add("", 0, 0, 0, "", null);
            }
            GV_PostharvestHandling.DataBind();
            DateTime dt = DateTime.Now;

            txtfromDatetime.Text = "01/" + DateTime.Now.ToString("MM/yyyy");
            txttoDatetime.Text   = DateTime.Now.ToString("dd/MM/yyyy");
            LoadPages();
        }
Ejemplo n.º 3
0
        protected void LoadPages()
        {
            int nPageNumber = int.Parse(txtPageNumber.Text);
            int nPageSize   = int.Parse(txtPageSize.Text);

            int nTotalRecord = PostharvestHandling_Data.Count(Session["EmployeeKey"].ToInt(), DDLSeeds.SelectedValue.ToInt());

            if (nTotalRecord > nPageSize)
            {
                PageNumbers.Visible = true;
                DataTable nTable = TNLibrary.WEB.LoadDataToToolboxWeb.LoadPageSize(nPageSize, nTotalRecord, nPageNumber);

                PageNumbers.SelectedIndex = (nPageNumber - 1) - (int.Parse(nTable.Rows[0][0].ToString()) - 1);
                PageNumbers.DataSource    = nTable;
                PageNumbers.DataBind();
            }
            else
            {
                PageNumbers.Visible = false;
            }
        }
Ejemplo n.º 4
0
        protected void GrDelete(object sender, CommandEventArgs e)
        {
            int nPageNumber             = int.Parse(txtPageNumber.Text);
            int nPageSize               = int.Parse(txtPageSize.Text);
            SessionUserLogin nUserLogin = (SessionUserLogin)Session["UserLogin"];

            nUserLogin.CheckRole("CU0013");
            if (!nUserLogin.Role.Del)
            {
                Response.Write("<script >alert('Bạn không có quyền xóa danh mục này!')</script>");
            }
            else
            {
                try
                {
                    int mKey = int.Parse(e.CommandArgument.ToString());
                    PostharvestHandling_Info info = new PostharvestHandling_Info(mKey);
                    if ((DateTime.Now - info.Datetime).TotalDays > 7)
                    {
                        Response.Write("<script >alert('Dữ liệu đã quá 7 ngày, không được phép xóa!')</script>");
                    }
                    else
                    {
                        info.Delete();
                        DataTable nTable = PostharvestHandling_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue.ToInt());
                        if (nTable.Rows.Count == 0)
                        {
                            nTable.Rows.Add("", 0, 0, 0, "", null);
                        }
                        GV_PostharvestHandling.DataSource = nTable;
                        GV_PostharvestHandling.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }