protected void dgMailDetailss_SelectedIndexChanged(object sender, EventArgs e) { int iSMTPID = Convert.ToInt32(dgMailServerDetails.DataKeys[dgMailServerDetails.SelectedIndex].ToString()); hfId.Value = iSMTPID.ToString(); //SessionHandler"MailDetailsID"] = iMailDetailsID; SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO[] oSMTPData = oSMTPMaster.GetSMTPDetails(iSMTPID); if (oSMTPData.Length > 0) { txtSMTPServer.Text = oSMTPData[0].SMTPServer; txtFromDisplayName.Text = oSMTPData[0].FromDisplayName; txtFromId.Text = oSMTPData[0].FromEmailId; txtPassword.Text = oSMTPData[0].SMTPPassword; txtPort.Text = oSMTPData[0].Port.ToString(); txtReplyToId.Text = oSMTPData[0].ReplyToId; txtUserId.Text = oSMTPData[0].SMTPUserId; chkActive.Checked = oSMTPData[0].Active; } oSMTPMaster = null; oSMTPData = null; //btnAddNew.Enabled = false; //btnCancel.Enabled = true; btnDelete.Enabled = true; btnCancel.Visible = true; btnEdit.Text = "Update"; //btnSave.Enabled = false; lblStatus.Text = ""; }
private bool ValidateValues() { SMTPMaster SMTPMaster = new SMTPMaster(); if (txtSMTPServer.Text.Trim() == "") { lblStatus.Text = "Please enter Smtp Server."; return(false); } if (txtFromId.Text.Trim() == "") { lblStatus.Text = "Please enter From email id."; return(false); } if (txtReplyToId.Text.Trim() == "") { lblStatus.Text = "Please enter Reply email id."; return(false); } if (txtFromDisplayName.Text.Trim() == "") { lblStatus.Text = "Please enter From display name."; return(false); } /*if (txtUserId.Text.Trim() == "") * { * lblStatus.Text = "Please enter SMTP user id."; * return false; * } * if (txtPassword.Text.Trim() == "") * { * lblStatus.Text = "Please enter the SMTP password."; * }*/ if (txtPort.Text.Trim() == "") { lblStatus.Text = "Please enter the SMTP port."; } int port; if (!int.TryParse(txtPort.Text.Trim(), out port)) { lblStatus.Text = "SMTP port can be numeric only."; } if (!SMTPMaster.IsValidEmailId(txtFromId.Text)) { lblStatus.Text = "From Email Id is invalid."; } if (!SMTPMaster.IsValidEmailId(txtReplyToId.Text)) { lblStatus.Text = "Reply Email Id is invalid."; } return(true); }
private void Delete() { int Id = 0; bool bActionCompleted; if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Delete)) { return; } int.TryParse(hfId.Value, out Id); if (Id == 0) { lblStatus.Text = "Please click on edit again."; return; } if (txtSMTPServer.Text.Trim() == "") { lblStatus.Text = "Please enter the SMTP server."; return; } SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO oSMTPData = MapControlsToObject(); /* * * CHECK IF THE MailDetails WHICH IS TO BE DELETED HAS ANY ASSOCIATED RECORDS...IF YES, MOVE OUT OF THE FUNCTION ELSE PROCEED * IF THE OUTPUT OF sMessage IS "", THEN RECORD CAN BE DELETED, ELSE NOT * */ string sMessage = ""; GF.HasRecords(Convert.ToString(Id), "MailDetails", out sMessage); if (sMessage != "") { base.DisplayAlert(sMessage); btnDelete.Enabled = true; } else { bActionCompleted = oSMTPMaster.Delete(oSMTPData); if (bActionCompleted == true) { ClearPageControls(); RefreshGrid(); oSMTPData = null; oSMTPMaster = null; //lblStatus.Text = "Deleted"; base.DisplayAlert("The record has been deleted successfully."); } else { base.DisplayAlert("Error Occured while deletion: Please refer to the error log."); } //lblStatus.Text = "Error Occured while deletion: Please refer to the error log."; } }
protected void dgMailDetailss_DeleteCommand(object source, DataGridCommandEventArgs e) { int iSMTPID = Convert.ToInt32(dgMailServerDetails.DataKeys[e.Item.ItemIndex].ToString()); SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO oSMTPData = new SMTPDTO(); oSMTPData.SMTPId = iSMTPID; oSMTPMaster.Delete(oSMTPData); ClearPageControls(); RefreshGrid(); oSMTPData = null; oSMTPMaster = null; }
private SMTPDTO GetSMTPDetails() { SMTPDTO[] SMTPDTO; SMTPMaster SMTPMaster = new SMTPMaster(); SMTPDTO = SMTPMaster.GetSMTPDetails(true); if (SMTPDTO != null && SMTPDTO.Length > 0) { return(SMTPDTO[0]); } else { return(null); } }
private void RefreshGrid() { SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO[] oSMTPData = oSMTPMaster.GetSMTPDetails(); if (oSMTPData != null) { if (oSMTPData.Length > 0) { dgMailServerDetails.DataSource = oSMTPData; dgMailServerDetails.DataBind(); } } else { dgMailServerDetails.DataSource = null; dgMailServerDetails.DataBind(); } ClearPageControls(); oSMTPData = null; oSMTPMaster = null; }
private void Save() { if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Add)) { return; } bool bActionCompleted; SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO oSMTPData = MapControlsToObject(); bActionCompleted = oSMTPMaster.Insert(oSMTPData); if (bActionCompleted == true) { base.DisplayAlert("The record has been inserted successfully"); ClearPageControls(); } else { lblStatus.Text = "Error Occured while insertion: Please refer to the error log."; } }
private void Update() { if (!base.ValidateIfCommandAllowed(Request.Url.AbsoluteUri, ENums.PageCommand.Update)) { return; } bool bActionCompleted; if (ValidateValues() == false) { return; } int Id = 0; int.TryParse(hfId.Value, out Id); if (Id == 0) { lblStatus.Text = "Please click on edit again."; return; } SMTPMaster oSMTPMaster = new SMTPMaster(); SMTPDTO oSMTPData = MapControlsToObject(); bActionCompleted = oSMTPMaster.Update(oSMTPData); if (bActionCompleted == true) { base.DisplayAlert("The record has been updated successfully"); ClearPageControls(); } else { lblStatus.Text = "Error Occured while updation: Please refer to the error log."; } }