protected void btnDelete_Click(object sender, EventArgs e) { try { labelMessage.Text = string.Empty; using (CountryRT receiverTransfer = new CountryRT()) { hdIsDelete.Value = "true"; hdIsEdit.Value = "true"; Country country = CreateCountry(); if (country != null) { DivisionOrStateRT divOrStateRT = new DivisionOrStateRT(); //if(divOrStateRT.IsDivisionOrStateExistsInCountry(country.IID)) //{ // labelMessage.Text = "DivisionOrState Already Exist For This Country"; // labelMessage.ForeColor = System.Drawing.Color.Red; //} //else //{ receiverTransfer.UpdateCountry(country); labelMessage.Text = "Data successfully deleted..."; labelMessage.ForeColor = System.Drawing.Color.Green; //} } else { labelMessage.Text = "Data not deleted..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } LoadCountry(); ClearField(); SetButton(); } 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 (CountryRT receiverTransfer = new CountryRT()) { hdIsEdit.Value = "true"; //hdIsDelete.Value = "false"; Country country = CreateCountry(); DivisionOrStateRT divOrStateRT = new DivisionOrStateRT(); if (country != null) { if (receiverTransfer.IsCountryCodeExistOtherRows(country.IID, country.Code) && receiverTransfer.IsCountryCodeExistOtherRows(country.IID, country.Name)) { labelMessage.Text = "Country Code " + txtCode.Text + " & Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } if (receiverTransfer.IsCountryCodeExistOtherRows(country.IID, country.Code)) { labelMessage.Text = "Country Code " + txtCode.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } else if (receiverTransfer.IsCountryNameExistOtherRows(country.IID, country.Name)) { labelMessage.Text = "Country Name " + txtName.Text + " Already Exists!"; labelMessage.ForeColor = System.Drawing.Color.Red; return; } if (chkIsRemoved.Checked == true) { if (divOrStateRT.IsDivisionOrStateExistsInCountry(country.IID)) { labelMessage.Text = "DivisionOrState Already exist for This Country"; labelMessage.ForeColor = System.Drawing.Color.Red; } else { receiverTransfer.UpdateCountry(country); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { receiverTransfer.UpdateCountry(country); labelMessage.Text = "Data successfully updated..."; labelMessage.ForeColor = System.Drawing.Color.Green; } } else { labelMessage.Text = "Data not updated..."; labelMessage.ForeColor = System.Drawing.Color.Red; } } ClearField(); DoHideButtons(); btnSave.Visible = true; chkIsRemoved.Visible = false; LoadCountry(); } catch (Exception ex) { labelMessage.Text = "Error : " + ex.Message; labelMessage.ForeColor = System.Drawing.Color.Red; } }