private void btnDelete_Click(object sender, EventArgs e) { DataRow dr = getSelectedDataRow(); int selectedUserId = int.Parse(dtGridUser.SelectedRows[0].Cells["ID"].Value.ToString()); User user = convertSelectedRowDataToUser(); FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + USER_DELETE_API; string DATA = jsonSerialization.SerializeToString <User>(user); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Error occurred while deleting record.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void loadEmailSchedulerData() { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + GET_EMAILSCHEDULER_API; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String emailSchedulerResultJosn = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); emailSchedulerResultJosn = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var emailSchedulerCollection = jsonSerialization.DeserializeFromString <Result <List <EmailScheduler> > >(emailSchedulerResultJosn); if (emailSchedulerCollection.Value != null) { _dtEmailScheduler = ListtoDataTable.ToDataTable(emailSchedulerCollection.Value); dataGridEmailScheduler.DataSource = _dtEmailScheduler; gridDisplaySetting(); } }
private void frmUseList_Load(object sender, EventArgs e) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + USERAPI; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String userResultJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); userResultJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var userCollection = jsonSerialization.DeserializeFromString <Result <List <User> > >(userResultJson); if (userCollection.Value != null) { _dtUser = ListtoDataTable.ToDataTable(userCollection.Value); dtGridUser.DataSource = _dtUser; gridDisplaySetting(); } }
internal Planner GetPlanDataById(int planId) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_PLAN_BY_PLAN_ID, planId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String planerResultJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); planerResultJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var planner = jsonSerialization.DeserializeFromString <Result <Planner> >(planerResultJson); if (planner.Value != null) { return(planner.Value); } return(null); }
private void updateClient() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; Client client = new Client() { Name = txtName.Text, FatherName = txtFatherName.Text, MotherName = txtMotherName.Text, DOB = dtDOB.Value, PlaceOfBirth = txtPlaceOfBirth.Text, IsMarried = rdoMaritalStatusYes.Checked, MarriageAnniversary = dtMarriageAnniversary.Value, PAN = txtPan.Text, Aadhar = txtAadhar.Text, Occupation = txtOccupation.Text, CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; if (ClientId == 0) { apiurl = Program.WebServiceUrl + "/" + ADD_CLIENT_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_CLIENT_API; client.ID = ClientId; } string DATA = jsonSerialization.SerializeToString <Client>(client); WebClient webclient = new WebClient(); webclient.Headers["Content-type"] = "application/json"; webclient.Encoding = Encoding.UTF8; string json = webclient.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateUserDate() { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + USER_UPDATE_RAPI; User user = new User() { Id = _user.Id, UserName = txtUserName.Text, FirstName = txtFirstName.Text, LastName = txtLastName.Text, Password = FinancialPlanner.Common.DataEncrypterDecrypter.CryptoEngine.Encrypt(txtPassword.Text), UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName }; string DATA = jsonSerialization.SerializeToString <User>(user); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "PUT", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully."); } } }
private void loadApplicationConfig() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + GET_APPLICATIONCONFIG_API; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String appConfigJsobResult = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); appConfigJsobResult = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var appConfigCollection = jsonSerialization.DeserializeFromString <Result <List <ApplicationConfiguration> > >(appConfigJsobResult); if (appConfigCollection.Value != null) { _dtAppConfig = ListtoDataTable.ToDataTable(appConfigCollection.Value); } } catch (Exception ex) { MessageBox.Show(string.Format("Fail to load application data. Error:{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void loadArticleFormWithData() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + GET_EMAILARTICLES_API; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String emailArticleResultJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); emailArticleResultJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var emailArticleCollection = jsonSerialization.DeserializeFromString <Result <List <EmailArticle> > >(emailArticleResultJson); if (emailArticleCollection.Value != null) { _dtArticle = ListtoDataTable.ToDataTable(emailArticleCollection.Value); } } catch (Exception ex) { MessageBox.Show(string.Format("Fail to load application data. Error:{0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AuditTrail_Load(object sender, EventArgs e) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(AUDITLOGCONTROLLER_BY_USER, Program.CurrentUser.UserName); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String auditTrailJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); auditTrailJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var auditTrailCollection = jsonSerialization.DeserializeFromString <Result <List <Activities> > >(auditTrailJson); if (auditTrailCollection.Value != null) { _dtAuditTrail = ListtoDataTable.ToDataTable(auditTrailCollection.Value); dtGridAuditTrail.DataSource = _dtAuditTrail; gridDisplaySetting(); } }
private void loadPlanData() { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + string.Format(GET_PLAN_BY_CLIENTID_API, ClientId); HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(apiurl); request.Method = "GET"; String planerResultJson = String.Empty; using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { Stream dataStream = response.GetResponseStream(); StreamReader reader = new StreamReader(dataStream); planerResultJson = reader.ReadToEnd(); reader.Close(); dataStream.Close(); } var plannerCollection = jsonSerialization.DeserializeFromString <Result <List <Planner> > >(planerResultJson); if (plannerCollection.Value != null) { _dtPlanner = ListtoDataTable.ToDataTable(plannerCollection.Value); } }
private void btnAppPathSave_Click(object sender, EventArgs e) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; ApplicationConfiguration appConfig = new ApplicationConfiguration() { Category = "Server Setting", SettingName = "Application Path", SettingValue = txtAppPath.Text.Replace("'", "''"), CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; DataRow[] drCollection = _dtAppConfig.Select("SettingName = 'Application Path'"); if (drCollection.Count() == 0) { apiurl = Program.WebServiceUrl + "/" + ADD_APPLICATIONCONFIG_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_APPLICATIONCONFIG_API; appConfig.Id = int.Parse(drCollection[0][0].ToString()); } string DATA = jsonSerialization.SerializeToString <ApplicationConfiguration>(appConfig); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Unable to save record." + resultObject.ExceptionInfo, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateEmailArticleInfo() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; EmailArticle article = new EmailArticle() { GroupName = cmbGroup.Text, Title = txtArticleTitle.Text, ContentFilePath = txtArticleContentPath.Text, Description = txtArticleDesc.Text, CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; if (txtArticleTitle.Tag == null) { apiurl = Program.WebServiceUrl + "/" + ADD_EMAILARTICLE_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_EMAILARTICLE_API; article.ID = int.Parse(txtArticleTitle.Tag.ToString()); } string DATA = jsonSerialization.SerializeToString <EmailArticle>(article); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); loadArticleFormWithData(); btnSaveArticleInfo.Enabled = false; displayArtilceTreeView(_dtArticle); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updateConversation() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; ProspectClientConversation prosClientConv = new ProspectClientConversation() { ProspectClientId = _prospCustomer.ID, ConversationBy = txtConversationBy.Text, ConversationDate = dtConversation.Value, Remarks = txtRemarks.Text, CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; if (_prospCustomerConversation == null) { apiurl = Program.WebServiceUrl + "/" + ADD_CONVERSATION_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_CONVERSATION_API; prosClientConv.ID = _prospCustomerConversation.ID; } string DATA = jsonSerialization.SerializeToString <ProspectClientConversation>(prosClientConv); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void updatePlan() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; Planner planner = new Planner() { Name = cmbPlan.Text, ClientId = ClientId, StartDate = dtPlanStartDate.Value, CreatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), CreatedBy = Program.CurrentUser.Id, UpdatedOn = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")), UpdatedBy = Program.CurrentUser.Id, UpdatedByUserName = Program.CurrentUser.UserName, MachineName = System.Environment.MachineName }; if (cmbPlan.Tag.ToString() == "0" || cmbPlan.Tag.ToString() == "") { apiurl = Program.WebServiceUrl + "/" + ADD_PLAN_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_PLAN_API; planner.ID = int.Parse(cmbPlan.Tag.ToString()); } string DATA = jsonSerialization.SerializeToString <Planner>(planner); WebClient webclient = new WebClient(); webclient.Headers["Content-type"] = "application/json"; webclient.Encoding = Encoding.UTF8; string json = webclient.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void saveSMTPConfiguration() { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = string.Empty; List <ApplicationConfiguration> appConfigs = getSMTPConfig(); DataRow[] drCollection = _dtAppConfig.Select("Category = 'SMTP Setting'"); if (drCollection.Count() == 0) { apiurl = Program.WebServiceUrl + "/" + ADD_MULTIPAL_APPLICATIONCONFIG_API; } else { apiurl = Program.WebServiceUrl + "/" + UPDATE_MULTIPAL_APPLICATIONCONFIG_API; } string DATA = jsonSerialization.SerializeToString <List <ApplicationConfiguration> >(appConfigs); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record save successfully.", "Record Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); this.DialogResult = DialogResult.OK; this.Close(); } else { MessageBox.Show("Unable to save record." + resultObject.ExceptionInfo, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void removeRecord(TreeNode selectedNode) { try { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); string apiurl = Program.WebServiceUrl + "/" + DETELE_EMAILARATICLE_API; EmailArticle article = convertSelectedRowDataToEmailArticle(); string DATA = jsonSerialization.SerializeToString <EmailArticle>(article); WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(apiurl, "POST", DATA); if (json != null) { var resultObject = jsonSerialization.DeserializeFromString <Result>(json); if (resultObject.IsSuccess) { MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information); trvArticle.SelectedNode.Remove(); DataRow[] dr = _dtArticle.Select("ID =" + article.ID); if (dr.Count() > 0) { dr[0].Delete(); } } } } catch (Exception ex) { MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnLogin_Click(object sender, EventArgs e) { FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization(); User user = new User() { UserName = txtUserName.Text, Password = FinancialPlanner.Common.DataEncrypterDecrypter.CryptoEngine.Encrypt(txtPassword.Text), MachineName = Environment.MachineName }; string DATA = jsonSerialization.SerializeToString <User>(user); string loginUrl = Program.WebServiceUrl + "/" + AUTHENTICATIONAPI; WebClient client = new WebClient(); client.Headers["Content-type"] = "application/json"; client.Encoding = Encoding.UTF8; string json = client.UploadString(loginUrl, DATA); if (json != null) { Result <User> resultObject = jsonSerialization.DeserializeFromString <Result <User> >(json); if (resultObject.IsSuccess && resultObject.Value != null) { Program.CurrentUser = resultObject.Value; frmServerMain frmserMain = new frmServerMain(); this.Visible = false; frmserMain.ShowDialog(); this.Close(); } else { MessageBox.Show("Invalid user or credential.", "Login fail", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }