XSYL10103利用控件获取值也可以用自定义


  string CKID = this._page.GetControlValue("btnCKMC");
pu10103,btnCKMC是一个下拉框

namespace
XSYLKCGL { public class CKWLDY : ISuwfBus { /// <summary> /// initialization /// </summary> private SlnSuwfPage _page; void ISuwfBus.Initial(SlnSuwfPage page) { this._page = page; try { Button btnPZ = (Button)page.FindControl("btnPLBC"); btnPZ.Click += new EventHandler(btnPLBC_Click); } catch (Exception ex) { page.ShowMessage(ex.Message); } } void btnPLBC_Click(object sender, EventArgs e) { string Strsql = ""; string Strckwlsql = ""; string strMsg = ""; try { string strPKs = this._page.GetRowDataPrimaryKeys(); string CKID = this._page.GetControlValue("btnCKMC"); if (CKID.Length == 0) { _page.ShowMessage("请选择对应仓库"); return; } if (strPKs.Length ==0) { _page.ShowMessage("请选择至少一条数据"); return; } Strsql = String.Format(@"select * from wlzd_tb where id in ({0})", strPKs); DataTable dt = SlnDataAccess.GetDataTable(Strsql); if (dt == null || dt.Rows.Count == 0) { _page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "<script>alert('该物料表无相关记录');</script>"); return; } var lstSql = new List<string>(); foreach(DataRow row in dt.Rows) { string wlid = row["ID"].ToString(); string wlbh = row["WLBH"].ToString(); string wlsfyx = row["SFYX"].ToString(); string cksfdy = SlnDataAccess.GetValueBySql(String.Format("select count(*) from ckwldy_tb where ckid = '{0}' and wlid = '{1}'", CKID, wlid)).ToString(); string seqckwl = SlnDataAccess.GetSeqNumber("SEQCKWLDY").ToString(); if (wlsfyx == "0") { _page.ShowMessage("该物料无效,其编号为"+wlbh); return; } if (cksfdy == "1") { _page.ShowMessage("该物料已存在此仓库中,其编号为" + wlbh); return; } Strckwlsql = String.Format(@"insert into ckwldy_tb(id,ckid,wlid) values('"+ seqckwl + "','"+CKID+"','"+ wlid + "')"); lstSql.Add(Strckwlsql); } strMsg += SlnDataAccess.ExecuteSQL(lstSql); if (string.IsNullOrEmpty(strMsg)) { this._page.ShowMessage("保存操作成功"); this._page.btnQuery_Click(null, null); } else { this._page.ShowMessage("保存操作出错" + strMsg); } } catch(Exception ex) { _page.ShowMessage(ex.Message); } } } }

 

posted @ 2024-12-16 15:40  知行一体2  阅读(1)  评论(0编辑  收藏  举报