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.");
                }
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        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 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);
            }
        }
Example #6
0
        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);
            }
        }
Example #7
0
        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);
            }
        }
Example #10
0
        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);
                }
            }
        }