Example #1
0
        protected void btDelete_Click(object sender, EventArgs e)
        {
            ArrayList     pkArray = null;
            WHMatBLL      bll     = null;
            List <string> msgList = new List <string>();

            try
            {
                bll = BLLFactory.CreateBLL <WHMatBLL>();

                pkArray = GvHelper.GetPKValueByChk(this.GvList, 0, "cbxSelect", 0);

                for (int i = 0; i < this.GvList.Rows.Count; i++)
                {
                    CheckBox cbxSelect = this.GvList.Rows[i].Cells[0].FindControl("cbxSelect") as CheckBox;

                    if (cbxSelect.Checked == false)
                    {
                        continue;
                    }

                    WHMat mat = new WHMat();
                    mat.ID      = this.GvList.DataKeys[i]["ID"].ToString();
                    mat.MatName = this.GvList.Rows[i].Cells[2].Text;

                    //判断是否已使用
                    bool r = bll.IsUse(mat);
                    if (r == true)
                    {
                        msgList.Add(mat.MatName);
                        continue;
                    }

                    //删除
                    bll.Delete(mat);
                }
                string msg = string.Join(",", msgList.ToArray());
                if (msg != "")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "myjs", "MSI('提示','" + msg + "货品已使用,无法删除');", true);
                }

                this.BindData();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }