protected void lvPoliceStation_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "EditPoliceStation") { try { labelMessage.Text = string.Empty; chkIsRemovedPoliceStation.Visible = true; btnSave.Visible = false; btnUpdate.Visible = true; //btnDelete.Visible = true; btnCancel.Visible = true; int policeStationID = Convert.ToInt32(e.CommandArgument); hdPoliceStationID.Value = policeStationID.ToString(); using (PoliceStationRT receiverTransfer = new PoliceStationRT()) { PoliceStation policeStaion = receiverTransfer.GetPoliceStaionByID(policeStationID); FillPoliceStationForEdit(policeStaion); } } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } } }
private void LoadDropDownForPoliceStaion() { try { using (PoliceStationRT aPoliceStationRt = new PoliceStationRT()) { var policeStationList = aPoliceStationRt.GetPoliceStationByCountryIdAndDistrictId(Convert.ToInt32(hdCountryID.Value), Convert.ToInt64(dropdownDistrict.SelectedValue)); DropDownListHelper.Bind(dropdownPoliceStation, policeStationList, "Name", "IID"); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void LoadPoliceStationListView() { try { using (PoliceStationRT receiverTransfer = new PoliceStationRT()) { lvPoliceStation.DataSource = receiverTransfer.GetAllPoliceStationForListView(); lvPoliceStation.DataBind(); } } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; using (PoliceStationRT receiverTransfer = new PoliceStationRT()) { hdIsDelete.Value = "true"; hdIsEdit.Value = "true"; PoliceStation policeStaion = CreatePoliceStaion(); if (policeStaion != null) { PostOfficeRT postOfficeRT = new PostOfficeRT(); if (postOfficeRT.IsPostOfficeExistsInPoliceStation(Convert.ToInt32(policeStaion.IID))) { labelMessage.Text = "Post Office Already Exist for this Police Station"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdatePoliceStaion(policeStaion); labelMessage.Text = "Data successfully deleted..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not deleted..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } LoadPoliceStationListView(); DohideButton(); btnSave.Visible = true; ClearField(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { // labelMessage.Text = string.Empty; using (DistrictRT receiverTransfer = new DistrictRT()) { hdIsDelete.Value = "true"; hdIsEdit.Value = "true"; District district = CreateDistrict(); if (district != null) { PoliceStationRT policeStationRT = new PoliceStationRT(); if (policeStationRT.IsPoliceStationExistsInDistrict(Convert.ToInt32(district.IID))) { labelMessage.Text = " Police Station Already Exist for this Country !"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdateDistict(district); labelMessage.Text = "Data successfully deleted..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not deleted..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } LoadDistrictListView(); SetButton(); ClearField(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; using (PoliceStationRT receiverTransfer = new PoliceStationRT()) { hdIsEdit.Value = "true"; //hdIsDelete.Value = "false"; PoliceStation policeStaion = CreatePoliceStaion(); if (policeStaion != null) { //Exit If Both Police Staion Code & Name exist in Other rows if ((receiverTransfer.IsPoliceStaionCodeExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID)) && (receiverTransfer.IsPoliceStaionNameExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID))) { labelMessage.Text = "Police Staion Code " + txtCode.Text + "& Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } //Exit if Duplicate Police Station Code else if (receiverTransfer.IsPoliceStationCodeExistsInOtherRows(policeStaion.IID, policeStaion.Code)) { labelMessage.Text = "Police Staion Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } //Exit If Both Police Staion Code exist in Other rows else if (receiverTransfer.IsPoliceStaionCodeExistInOtherRows(policeStaion.IID, policeStaion.Code, policeStaion.DistrictID)) { labelMessage.Text = "Police Staion Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } //Exit If Both Police Staion Name exist in Other rows else if (receiverTransfer.IsPoliceStaionNameExistInOtherRows(policeStaion.IID, policeStaion.Name, policeStaion.DistrictID)) { labelMessage.Text = "Police Staion Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } if (chkIsRemovedPoliceStation.Checked == true) { PostOfficeRT postOfficeRT = new PostOfficeRT(); if (postOfficeRT.IsPostOfficeExistsInPoliceStation(Convert.ToInt32(policeStaion.IID))) { labelMessage.Text = "Post Office Already Exist for this Police Station"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdatePoliceStaion(policeStaion); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { receiverTransfer.UpdatePoliceStaion(policeStaion); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not updated..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } ClearField(); btnSave.Visible = true; DohideButton(); chkIsRemovedPoliceStation.Visible = false; LoadPoliceStationListView(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }
//private void LoadDropDownCountry(int? countryID) //{ // try // { // using (CountryRT receverTransfer = new CountryRT()) // { // List<Country> countryList = new List<Country>(); // if (countryID != null) // { // countryList.Add(receverTransfer.GetCountryByIID((int)countryID)); // } // else // { // countryList = receverTransfer.GetCountryAll(); // } // DropDownListHelper.Bind<Country>(ddlCountry, countryList, "Name", "IID", EnumCollection.ListItemType.Country); // } // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } //} //private void LoadDivisionOrState(int? divisionOrStateID) //{ // try // { // using (DivisionOrStateRT receverTransfer = new DivisionOrStateRT()) // { // List<DivisionOrState> divisionOrStateList = new List<DivisionOrState>(); // if (divisionOrStateID != null) // { // divisionOrStateList.Add(receverTransfer.GetDivisionOrStateByID((int)divisionOrStateID)); // } // else // { // divisionOrStateList = receverTransfer.GetDivisionOrStateAll(); // } // DropDownListHelper.Bind<DivisionOrState>(ddlDivisionOrState, divisionOrStateList, "Name", "IID", EnumCollection.ListItemType.State); // } // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } //} //private void LoadDropDownDistrict(int? districtID) //{ // try // { // using (DistrictRT receverTransfer = new DistrictRT()) // { // List<District> districtList = new List<District>(); // if (districtID != null) // { // districtList.Add(receverTransfer.GetDistrictByID((int)districtID)); // } // else // { // districtList = receverTransfer.GetAllDistrict(); // } // DropDownListHelper.Bind<District>(ddlDistrict, districtList, "Name", "IID", EnumCollection.ListItemType.District); // } // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } //} //private void LoadDivisionOrStateForCountry(int countryID) //{ // try // { // using (DivisionOrStateRT receverTransfer = new DivisionOrStateRT()) // { // List<DivisionOrState> divisionOrStateList = new List<DivisionOrState>(); // if (countryID != null) // { // divisionOrStateList = receverTransfer.GetDistrictOrStateForCountryID(countryID); // } // else // { // divisionOrStateList = receverTransfer.GetDivisionOrStateAll(); // } // DropDownListHelper.Bind<DivisionOrState>(ddlDivisionOrState, divisionOrStateList, "Name", "IID", EnumCollection.ListItemType.State); // } // } // catch (Exception ex) // { // throw new Exception(ex.Message, ex); // } //} protected void btnSave_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; //int districtID= Convert.ToInt32(ddlDistrict.SelectedValue); int districtID = int.Parse(txtDistrictID.Text); using (PoliceStationRT receiverTransfer = new PoliceStationRT()) { //List<PoliceStation> policeStationList = new List<PoliceStation>(); //policeStationList = receiverTransfer.GetPoliceStaionByName(txtName.Text); //if (policeStationList != null && policeStationList.Count > 0) if (receiverTransfer.IsPoliceStationCodeExists(txtCode.Text, districtID) && receiverTransfer.IsPoliceStationNameExists(txtName.Text, districtID)) { labelMessage.Text = "Police Staion Code " + txtCode.Text + "& Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsPoliceStationCodeExists(txtCode.Text)) { labelMessage.Text = "Police Staion Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsPoliceStationCodeExists(txtCode.Text, districtID)) { labelMessage.Text = "Police Staion Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsPoliceStationNameExists(txtName.Text, districtID)) { labelMessage.Text = "Police Staion Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } PoliceStation policeStation = CreatePoliceStaion(); receiverTransfer.AddPoliceStaion(policeStation); if (policeStation.IID > 0) { labelMessage.Text = "Data successfully saved..."; labelMessage.ForeColor = System.Drawing.Color.Green; } else { labelMessage.Text = "Data not saved..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } ClearField(); LoadPoliceStationListView(); chkIsRemovedPoliceStation.Visible = false; } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }
protected void btnUpdate_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; using (DistrictRT receiverTransfer = new DistrictRT()) { hdIsEdit.Value = "true"; hdIsDelete.Value = "false"; District district = CreateDistrict(); PoliceStationRT policeStationRT = new PoliceStationRT(); if (district != null) { if (receiverTransfer.IsDistCodeExistInOtherRows(district.IID, district.Code, district.DivisionOrStateID) && receiverTransfer.IsDistCodeExistInOtherRows(district.IID, district.Code, district.DivisionOrStateID)) { labelMessage.Text = "District Code " + txtCode.Text + " & Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistCodeExistInOtherRows(district.IID, district.Code)) { labelMessage.Text = "District Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistCodeExistInOtherRows(district.IID, district.Code, district.DivisionOrStateID)) { labelMessage.Text = "District Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistNameExistInOtherRows(district.IID, district.Name, district.DivisionOrStateID)) { labelMessage.Text = "District Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } if (chkIsRemovedDistrict.Checked == true) { if (policeStationRT.IsPoliceStationExistsInDistrict(Convert.ToInt32(district.IID))) { labelMessage.Text = " Police Station Already Exist for this Country !"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdateDistict(district); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { receiverTransfer.UpdateDistict(district); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not updated..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } ClearField(); SetButton(); chkIsRemovedDistrict.Visible = false; LoadDistrictListView(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }