private void btnDel_Click(object sender, ImageClickEventArgs e) { string PKID; int selectedIndex = -1; foreach (DataGridItem item in this.dgCWNewMarrige.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.dgCWNewMarrige.Items[selectedIndex].Cells[1].Text; Wicresoft.Session.Session session = new Wicresoft.Session.Session(); BusinessMapping.CWNewMarrige bo = new BusinessMapping.CWNewMarrige(); bo.SessionInstance = session; BusinessFilter filter = new BusinessFilter("CWNewMarrige"); 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.CWNewMarrige bo = new BusinessMapping.CWNewMarrige(); bo.SessionInstance = new Wicresoft.Session.Session(); BusinessFilter filter = new BusinessFilter("CWNewMarrige"); 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.MaleIDCardNo.Value = this.txtMaleIDCardNo.Text.Trim(); bo.MaleName.Value = this.txtMaleName.Text.Trim(); bo.MaleAddress.Value = this.txtMaleAddress.Text.Trim(); bo.MaleLinkPhone.Value = this.txtMaleLinkPhone.Text.Trim(); bo.FemaleIDCardNo.Value = this.txtFemaleIDCardNo.Text.Trim(); bo.FemaleName.Value = this.txtFemaleName.Text.Trim(); bo.FemaleAddress.Value = this.txtFemaleAddress.Text.Trim(); bo.FemaleLinkPhone.Value = this.txtFemaleLinkPhone.Text.Trim(); if (this.txtMarrigeDate.Text != "") { bo.MarrigeDate.Value = Convert.ToDateTime(this.txtMarrigeDate.Text); } if (this.ddlIsPregnant.SelectedValue != string.Empty && this.ddlIsPregnant.SelectedValue != "0") { bo.IsPregnant.Value = Convert.ToInt32(this.ddlIsPregnant.SelectedValue); } else { bo.IsPregnant.Value = 0; } if (this.txtExpectDate.Text != "") { bo.ExpectDate.Value = Convert.ToDateTime(this.txtExpectDate.Text); } if (this.txtVillageDate.Text != "") { bo.VillageDate.Value = Convert.ToDateTime(this.txtVillageDate.Text); } bo.MarrigeNo.Value = this.txtMarrigeNo.Text.Trim(); bo.Memo.Value = this.txtMemo.Text.Trim(); bo.Update(); string strSql = string.Empty; if (this.txtMarrigeDate.Text == "" && bo.MarrigeDate.Value != DateTime.MinValue) { strSql += string.Format("UPDATE CWNewMarrige SET MarrigeDate = NULL WHERE PKID = {0}; ", this.PKID); } if (this.txtExpectDate.Text == "" && bo.ExpectDate.Value != DateTime.MinValue) { strSql += string.Format("UPDATE CWNewMarrige SET ExpectDate = NULL WHERE PKID = {0}; ", this.PKID); } if (this.txtVillageDate.Text == "" && bo.VillageDate.Value != DateTime.MinValue) { strSql += string.Format("UPDATE CWNewMarrige SET VillageDate = NULL WHERE PKID = {0}; ", this.PKID); } if (strSql != string.Empty) { Wicresoft.Session.Session session = new Wicresoft.Session.Session(); session.SqlHelper.ExecuteNonQuery(strSql, CommandType.Text); } } }