protected void lnkOk1_Click(object sender, EventArgs e) { if (ddlState.SelectedValue == "0") { lblerror.Visible = true; } else { AdministrationEDSC.CouncilDTRow dr = new AdministrationEDSC.CouncilDTDataTable().NewCouncilDTRow(); dr = GetData(); string userName = SystemConstants.DevUser; //Membership.GetUser().UserName; AdministrationDAC dac = new AdministrationDAC(); if (Mode == SystemConstants.FormMode.New) { dac.CreateCouncil(userName, dr); } else if (Mode == SystemConstants.FormMode.Edit) { dac.UpdateCouncil(userName, dr); } Mode = SystemConstants.FormMode.View; SetData(dr); } }
public AdministrationEDSC.CouncilDTRow GetData() { AdministrationEDSC.CouncilDTRow dr = new AdministrationEDSC.CouncilDTDataTable().NewCouncilDTRow(); if (!string.IsNullOrEmpty(hdnCouncilID.Value)) { dr.ID = Convert.ToInt32(hdnCouncilID.Value); } dr.Name = txtAddEditName.Text; dr.Value = txtAddEditName.Text.Replace(" ", "_"); dr.Description = txtDesc.Text; dr.StateID = Convert.ToInt32(ddlState.SelectedValue); dr.CreatedBy = hdnCreatedBy.Value; dr.CreatedDatetime = Convert.ToDateTime(hdnCreatedDate.Value); return(dr); }
private AdministrationEDSC.CouncilDTDataTable GetSelected() { AdministrationEDSC.CouncilDTDataTable dt = new AdministrationEDSC.CouncilDTDataTable(); foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { CheckBox CheckBox1 = row.FindControl("chkboxSelected") as CheckBox; HiddenField hdnID = row.FindControl("hdnID") as HiddenField; var dr = dt.NewCouncilDTRow(); if (CheckBox1.Checked) { dr.ID = Convert.ToInt32(hdnID.Value); dt.AddCouncilDTRow(dr); } } } return(dt); }
protected void lnkDelete_Click(object sender, EventArgs e) { AdministrationBFC bfc = new AdministrationBFC(); AdministrationEDSC.CouncilDTDataTable dt = GetSelected(); foreach (AdministrationEDSC.CouncilDTRow dr in dt) { bool complete = bfc.DeleteCouncil(dr.ID); if (complete) { divSuccess.Visible = complete; divError.Visible = !complete; lblSuccess.Text = "Selected Council has been successfully deleted"; } else { divSuccess.Visible = complete; divError.Visible = !complete; lblError.Text = "Cannot delete selected Council, one or more suburb(s) are linked to this Council. Consider to delete or modify the Suburb(s) and try again."; } } Refresh(); }