Esempio n. 1
0
        protected void btnFind_Click(object sender, EventArgs e)
        {
            dgv.Disabled = false;
            SelectCommandBuilder select = new SelectCommandBuilder();
            string sql = "SELECT name, spec, texture FROM m_materials";

            if (txtM_name.Text != string.Empty)
            {
                sql += " where name like '" + txtM_name.Text.Trim() + "%'";
            }
            SqlDataReader       dr      = select.ExecuteReader(sql);
            List <AddGoodsInfo> addinfo = new List <AddGoodsInfo>();

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    AddGoodsInfo info = new AddGoodsInfo()
                    {
                        name = dr.GetString(0),
                        spec = dr.IsDBNull(1) ? "" : dr.GetString(1),
                        cz   = dr.IsDBNull(2) ? "" : dr.GetString(2)
                    };
                    addinfo.Add(info);
                }
            }
            gvShowData.DataSource = addinfo;
            gvShowData.DataBind();
        }
Esempio n. 2
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtM_name.Text))
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('名称为空')</script>", false);
                txtM_name.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(txtSpec.Text))
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('规格为空')</script>", false);
                txtSpec.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(txtCz.Text))
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('材质为空')</script>", false);
                txtCz.Focus();
                return;
            }
            else if (string.IsNullOrEmpty(txtQty.Text))
            {
                ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "alert", "<script>alert('数量为空')</script>", false);
                txtCz.Focus();
                return;
            }
            AddGoodsInfo info = new AddGoodsInfo()
            {
                name = txtM_name.Text.Trim(), spec = txtSpec.Text.Trim(), cz = txtCz.Text.Trim(), qty = int.Parse(txtQty.Text.Trim())
            };

            AddList.Add(info);
            gvAddData.DataSource = AddList;
            gvAddData.DataBind();
            txtM_name.Text = string.Empty;
            txtSpec.Text   = string.Empty;
            txtCz.Text     = string.Empty;
            txtQty.Text    = string.Empty;
            txtM_name.Focus();
        }
Esempio n. 3
0
 protected void btnSure_Click(object sender, EventArgs e)
 {
     //List<AddGoodsInfo> aList = new List<AddGoodsInfo>();
     if (gvdata != null && gvdata.Rows.Count != 0)
     {
         for (int i = 0; i < gvdata.Rows.Count; i++)
         {
             if (gvdata.Rows[i].Cells[2].Text == "&nbsp;")
             {
                 continue;
             }
             AddGoodsInfo a = new AddGoodsInfo();
             a.name = gvdata.Rows[i].Cells[2].Text;
             a.cz   = gvdata.Rows[i].Cells[3].Text;
             a.qty  = gvdata.Rows[i].Cells[4].Text == "&nbsp;" ? 0 : int.Parse(gvdata.Rows[i].Cells[4].Text);
             a.spec = gvdata.Rows[i].Cells[6].Text;
             AddList.Add(a);
         }
     }
     gvAddData.DataSource = AddList;
     gvAddData.DataBind();
     gvdata.DataSource = null;
     gvdata.DataBind();
 }