Example #1
0
        protected void LoadInfo(int Key)
        {
            Pesticide_Buy_Info info = new Pesticide_Buy_Info(Key);

            if (Key == 0)
            {
                DateTime time = DateTime.Now;
                txtDatetime.Text = time.ToString("dd/MM/yyyy");
            }
            else
            {
                txtDatetime.Text = info.DatetimeBuy.ToString("dd/MM/yyyy");
            }
            DDLUnit.Text      = LoadDataToToolboxWeb.GetName("SELECT Name FROM PUL_Unit where ID = " + info.UnitKey.ToString());
            DDLPesticide.Text = LoadDataToToolboxWeb.GetName("SELECT Trade_Name FROM PUL_Pesticides where PesticideKey = " + info.PesticideKey.ToString());
            txtQuantity.Text  = info.Quantity.ToString();
            //txtPrice.Text = info.Price;
            txtAddress.Text = info.Address;
            DDLSeeds.Text   = LoadDataToToolboxWeb.GetName("SELECT SeedsName FROM PUL_Seeds where SeedsKey = (Select SeedsKey from PUL_SeedProcess where SeedProcessKey  = (Select SeedsKey from PUL_Pesticide_Buy where PesticideBuyKey = " + info.PesticideBuyKey.ToString() + " ))");
        }
Example #2
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("CU0004");
            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());
                    Pesticide_Buy_Info info = new Pesticide_Buy_Info(mKey);
                    if ((DateTime.Now - info.DatetimeBuy).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 = Pesticide_Buy_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue);
                        if (nTable.Rows.Count == 0)
                        {
                            nTable.Rows.Add("", 0, null, 0, 0, "", "", "", "", "", 0);
                        }
                        GV_Pesticide_Buy.DataSource = nTable;
                        GV_Pesticide_Buy.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }