private void btnDel_Click(object sender, ImageClickEventArgs e) { string PKID; int selectedIndex = -1; foreach (DataGridItem item in this.dgCWOneChildAward.Items) { if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem) { if (((System.Web.UI.WebControls.RadioButton)item.Cells[0].Controls[1]).Checked) { selectedIndex = item.ItemIndex; break; } } } if (selectedIndex != -1) { PKID = this.dgCWOneChildAward.Items[selectedIndex].Cells[1].Text; Wicresoft.Session.Session session = new Wicresoft.Session.Session(); BusinessMapping.CWOneChildAward bo = new BusinessMapping.CWOneChildAward(); bo.SessionInstance = session; BusinessFilter filter = new BusinessFilter("CWOneChildAward"); filter.AddFilterItem("PKID", PKID.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND); bo.AddFilter(filter); bo.Load(); if (bo.HaveRecord) { bo.IsValid.Value = false; bo.Update(); // Reload Data ucCustomPaging.LoadData(ucCustomPaging.CurrentPage); } } }
public void Update() { BusinessMapping.CWOneChildAward bo = new BusinessMapping.CWOneChildAward(); bo.SessionInstance = new Wicresoft.Session.Session(); BusinessFilter filter = new BusinessFilter("CWOneChildAward"); filter.AddFilterItem("PKID", this.PKID.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND); bo.AddFilter(filter); bo.Load(); if (bo.HaveRecord) { int userID = GlobalFacade.SystemContext.GetContext().UserID; if (this.gpCWInfo.SelectedValue != string.Empty && this.gpCWInfo.SelectedValue != "0") { bo.FK_CWID.Value = Convert.ToInt32(this.gpCWInfo.SelectedValue); } else { bo.FK_CWID.Value = 0; } bo.OwnIDCardNo.Value = this.txtOwnIDCardNo.Text.Trim(); bo.OwnName.Value = this.txtOwnName.Text.Trim(); bo.ChildIDCardNo.Value = this.txtChildIDCardNo.Text.Trim(); bo.ChildName.Value = this.txtChildName.Text.Trim(); if (this.txtBirthDate.Text != "") { bo.BirthDate.Value = Convert.ToDateTime(this.txtBirthDate.Text); } bo.OneChildNo.Value = this.txtOneChildNo.Text.Trim(); if (this.txtRealMonth.Text.Trim() != "") { bo.RealMonth.Value = Convert.ToInt32(this.txtRealMonth.Text.Trim()); } if (this.txtAwardFee.Text.Trim() != "") { bo.AwardFee.Value = Convert.ToDecimal(this.txtAwardFee.Text.Trim()); } bo.LinkPhone.Value = this.txtLinkPhone.Text.Trim(); bo.AuthName.Value = this.txtAuthName.Text.Trim(); bo.ABCNo.Value = this.txtABCNo.Text.Trim(); bo.AuthIDCardNo.Value = this.txtAuthIDCardNo.Text.Trim(); bo.AwardYear.Value = this.txtAwardYear.Text.Trim(); bo.Memo.Value = this.txtMemo.Text.Trim(); bo.Update(); string strSql = string.Empty; if (this.txtBirthDate.Text == "" && bo.BirthDate.Value != DateTime.MinValue) { strSql += string.Format("UPDATE CWOneChildAward SET BirthDate = NULL WHERE PKID = {0}; ", this.PKID); } if (strSql != string.Empty) { Wicresoft.Session.Session session = new Wicresoft.Session.Session(); session.SqlHelper.ExecuteNonQuery(strSql, CommandType.Text); } } }