示例#1
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("CA0002");
            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_Info info = new Fertilizer_Info(mKey);
                    info.Delete();
                    DataTable nTable = Fertilizers_Data.GetList(nPageSize, nPageNumber, txtSearch.Text);
                    GV_Fertilizers.DataSource = nTable;
                    GV_Fertilizers.DataBind();
                }
                catch
                {
                    Response.Write("<script >alert('Có lỗi gì đó vui lòng thử lại!')</script>");
                }
            }
        }
示例#2
0
        protected void SaveInfo()
        {
            Fertilizer_Info info = new Fertilizer_Info(int.Parse(txtKey.Text));

            info.TradeName = txtTrade.Text;

            if (int.Parse(DLLUnit.SelectedValue) == 0)
            {
                info.UnitKey = 1;
            }
            else
            {
                info.UnitKey = int.Parse(DLLUnit.SelectedValue);
            }
            if (int.Parse(DLLCommon.SelectedValue) == 0)
            {
                info.CommonKey = 217;
            }
            else
            {
                info.CommonKey = int.Parse(DLLCommon.SelectedValue);
            }

            info.CompanyKey  = int.Parse(DLLCompany.SelectedValue);
            info.CategoryKey = int.Parse(DLLCategoryID.SelectedValue);
            if (FileUploadKML.HasFile)
            {
                try
                {
                    FileUploadKML.SaveAs(Server.MapPath("~/Img/Fertilizer/") + info.FertilizersKey.ToString() + ".png");
                    info.Images = "../Img/Fertilizer/" + info.FertilizersKey.ToString() + ".png";
                }
                catch (Exception ex)
                {
                }
            }
            else
            {
                info.Images = "../Img/Fertilizer/Default.png";
            }
            info.Save();
        }
示例#3
0
        protected void LoadInfo(int Key)
        {
            Fertilizer_Info info = new Fertilizer_Info(Key);

            txtTrade.Text = info.TradeName;
            if (Key == 0)
            {
                DLLCommon.SelectedValue     = "218";
                DLLCompany.SelectedValue    = "234";
                DLLUnit.SelectedValue       = "1";
                DLLCategoryID.SelectedValue = "2";
            }
            else
            {
                DLLCommon.SelectedValue     = info.CommonKey.ToString();
                DLLUnit.SelectedValue       = info.UnitKey.ToString();
                DLLCompany.SelectedValue    = info.CompanyKey.ToString();
                DLLCategoryID.SelectedValue = info.CategoryKey.ToString();
            }

            imgLink.ImageUrl = info.Images;
        }