Beispiel #1
0
        protected void LoadInfo(int Key)
        {
            Fertilizer_Buy_Info info = new Fertilizer_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());
            DDLFertilizer.Text = LoadDataToToolboxWeb.GetName("SELECT TradeName FROM PUL_Fertilizers where FertilizersKey = " + info.FertilizerKey.ToString());// = info.FertilizerKey.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_Fertilizer_Buy where FertilizerBuyKey = " + info.FertilizerBuyKey.ToString() + "))");
        }
Beispiel #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("CU0002");
            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());
                    Fertilizer_Buy_Info info = new Fertilizer_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 = Fertilizer_Buy_Data.GetList(Convert.ToInt16(Session["EmployeeKey"]), nPageSize, nPageNumber, DDLSeeds.SelectedValue);
                        if (nTable.Rows.Count == 0)
                        {
                            nTable.Rows.Add("", 0, null, "", 0, 0, 0, "", "", "", "", 0);
                        }
                        GV_Fertilizer_Buy.DataSource = nTable;
                        GV_Fertilizer_Buy.DataBind();
                        LoadPages();
                    }
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }