private void btnDel_Click(object sender, ImageClickEventArgs e) { string PKID; int selectedIndex = -1; foreach (DataGridItem item in this.dgCWOneChild.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.dgCWOneChild.Items[selectedIndex].Cells[1].Text; Wicresoft.Session.Session session = new Wicresoft.Session.Session(); BusinessMapping.CWOneChild bo = new BusinessMapping.CWOneChild(); bo.SessionInstance = session; BusinessFilter filter = new BusinessFilter("CWOneChild"); filter.AddFilterItem("PKID", PKID.ToString(), Operation.Equal, FilterType.NumberType, AndOr.AND); bo.AddFilter(filter); bo.Load(); if (bo.HaveRecord) { bo.ModifyUser.Value = GlobalFacade.SystemContext.GetContext().UserID; bo.ModifyTime.Value = DateTime.Now; bo.IsValid.Value = false; bo.Update(); // Reload Data ucCustomPaging.LoadData(ucCustomPaging.CurrentPage); } } }
public void Update() { BusinessMapping.CWOneChild bo = new BusinessMapping.CWOneChild(); bo.SessionInstance = new Wicresoft.Session.Session(); BusinessFilter filter = new BusinessFilter("CWOneChild"); 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.IDCardNo.Value = this.txtIDCardNo.Text.Trim(); bo.ChildName.Value = this.txtChildName.Text.Trim(); if (this.ddlSex.SelectedValue != string.Empty && this.ddlSex.SelectedValue != "0") { bo.Sex.Value = Convert.ToInt32(this.ddlSex.SelectedValue); } else { bo.Sex.Value = 0; } bo.FathIDCardNo.Value = this.txtFathIDCardNo.Text.Trim(); bo.MothIDCardNo.Value = this.txtMothIDCardNo.Text.Trim(); bo.OneChildNo.Value = this.txtOneChildNo.Text.Trim(); bo.IssueOrg.Value = this.txtIssueOrg.Text.Trim(); if (this.txtBirthDate.Text != "") { bo.BirthDate.Value = Convert.ToDateTime(this.txtBirthDate.Text); } bo.InSchool.Value = this.txtInSchool.Text.Trim(); bo.FamilyAddress.Value = this.txtFamilyAddress.Text.Trim(); if (this.txtFamilyIncome.Text.Trim() != "") { bo.FamilyIncome.Value = Convert.ToDecimal(this.txtFamilyIncome.Text.Trim()); } bo.InsuNo.Value = this.txtInsuNo.Text.Trim(); bo.ModifyUser.Value = userID; bo.ModifyTime.Value = DateTime.Now; 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 CWOneChild 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); } } }