protected void lvDistrict_ItemCommand(object sender, ListViewCommandEventArgs e) { if (e.CommandName == "EditDistrict") { try { labelMessage.Text = string.Empty; chkIsRemovedDistrict.Visible = true; btnSave.Visible = false; btnUpdate.Visible = true; btnDelete.Visible = false; btnCancel.Visible = true; int districtID = Convert.ToInt32(e.CommandArgument); hdDistrictID.Value = districtID.ToString(); using (DistrictRT receiverTransfer = new DistrictRT()) { District district = receiverTransfer.GetDistrictByID(districtID); FillDistictForEdit(district); } } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } } }
private void LoadDropDownForDistrict() { try { using (DistrictRT aDistrictRt = new DistrictRT()) { var districtList = aDistrictRt.GetDistrictByCountryId(Convert.ToInt32(hdCountryID.Value)); DropDownListHelper.Bind(dropdownDistrict, districtList, "Name", "IID"); } } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void LoadDistrictListView() { try { using (DistrictRT receiverTransfer = new DistrictRT()) { lvDistrict.DataSource = receiverTransfer.GetAllDistrictForListView();; lvDistrict.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 (DivisionOrStateRT receiverTransfer = new DivisionOrStateRT()) { //hdIsDelete.Value = "true"; hdIsEdit.Value = "true"; DivisionOrState divisionOrState = CreateDivsionOrState(); if (divisionOrState != null) { DistrictRT districtRT = new DistrictRT(); if (districtRT.IsDistrictExistsInDivision(Convert.ToInt32(divisionOrState.IID))) { labelMessage.Text = "District Already Exist For This Division Or State"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdateDivisionOrState(divisionOrState); labelMessage.Text = "Data successfully deleted..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not deleted..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } LoadDivisionOrState(); 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 (DivisionOrStateRT receiverTransfer = new DivisionOrStateRT()) { hdIsEdit.Value = "true"; DistrictRT districtRT = new DistrictRT(); //hdIsDelete.Value = "false"; DivisionOrState divisionOrState = CreateDivsionOrState(); if (divisionOrState != null) { if ((receiverTransfer.IsDivOrStateCodeExistInOterRows(divisionOrState.IID, divisionOrState.Code, divisionOrState.CountryID)) && (receiverTransfer.IsDivOrStateNameExistInOterRows(divisionOrState.IID, divisionOrState.Name, divisionOrState.CountryID))) { labelMessage.Text = "Division Or State Code " + txtCode.Text + " & Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDivOrStateCodeExisInOterRow(divisionOrState.IID, divisionOrState.Code)) { labelMessage.Text = "Division Or State Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDivOrStateCodeExistInOterRows(divisionOrState.IID, divisionOrState.Code, divisionOrState.CountryID)) { labelMessage.Text = "Division Or State Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDivOrStateNameExistInOterRows(divisionOrState.IID, divisionOrState.Name, divisionOrState.CountryID)) { labelMessage.Text = "Division Or State Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } if (chkIsRemovedDivOrState.Checked == true) { if (districtRT.IsDistrictExistsInDivision(Convert.ToInt32(divisionOrState.IID))) { labelMessage.Text = "District already exist for this Division Or State"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdateDivisionOrState(divisionOrState); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { receiverTransfer.UpdateDivisionOrState(divisionOrState); 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(); chkIsRemovedDivOrState.Visible = false; LoadDivisionOrState(); } 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; } }
protected void btnSave_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; int divOrStateID = Convert.ToInt32(txtDivisionOrStateID.Text); //int contryID = Convert.ToInt32(txtCountryID.Text); using (DistrictRT receiverTransfer = new DistrictRT()) { //List<District> districtList = new List<District>(); // Comment by Hasan 2015.02.16 //districtList = receiverTransfer.GetDistrictByName(txtName.Text); //if (districtList != null && districtList.Count > 0) if (receiverTransfer.IsDistrictCodeExists(txtCode.Text, divOrStateID) && receiverTransfer.IsDistrictNameExists(txtName.Text, divOrStateID)) { labelMessage.Text = "District Code " + txtCode.Text + " & Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistrictCodeExists(txtCode.Text)) { labelMessage.Text = "District Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistrictCodeExists(txtCode.Text, divOrStateID)) { labelMessage.Text = "District Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsDistrictNameExists(txtName.Text, divOrStateID)) { labelMessage.Text = "District Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } District district = CreateDistrict(); receiverTransfer.AddDistrict(district); if (district.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(); LoadDistrictListView(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }