private void updateClient()
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = string.Empty;

                ProspectClient prosCustomer = new ProspectClient()
                {
                    Name                = txtName.Text,
                    Occupation          = txtOccupation.Text,
                    PhoneNo             = txtPhoneNo.Text,
                    Email               = txtEmail.Text,
                    Event               = txtEvent.Text,
                    EventDate           = dtEventDate.Value,
                    ReferedBy           = txtRefBy.Text,
                    IsConvertedToClient = chkIsConvertedToCustomer.Checked,
                    StopSendingEmail    = chkStopSendingEmail.Checked,
                    Remarks             = txtRemark.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 (_prospectClient == null)
                {
                    apiurl = Program.WebServiceUrl + "/" + ADD_PROSPECTCLIENT_API;
                }
                else
                {
                    apiurl          = Program.WebServiceUrl + "/" + UPDATE_PROSPECTCLIENT_API;
                    prosCustomer.ID = _prospectClient.ID;
                }

                string DATA = jsonSerialization.SerializeToString <ProspectClient>(prosCustomer);

                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();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to save record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + AUDITLOGCONTROLLER;

                Activities activity = new Activities();
                activity.ActivityTypeValue = ActivityType.Logout;
                activity.EntryType         = EntryStatus.Success;
                activity.SourceType        = Source.Server;
                activity.HostName          = Environment.MachineName;
                activity.UserName          = Program.CurrentUser.UserName;

                string DATA = jsonSerialization.SerializeToString <Activities>(activity);

                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);
                }
            }
            catch (Exception ex)
            {
                Logger.LogDebug(ex.ToString());
            }
        }
Example #3
0
        private HttpWebRequest setWebRequest()
        {
            JSONSerialization jsonSerialization = new JSONSerialization();
            HttpWebRequest    request           = (HttpWebRequest)HttpWebRequest.Create(_url);

            string DATA = (_objectType == null) ? string.Empty : jsonSerialization.SerializeToString <object>(_objectType);
            var    data = Encoding.ASCII.GetBytes(DATA);

            request.Method        = _method;
            request.ContentType   = "application/json";
            request.ContentLength = data.Length;
            request.Referer       = _url.Substring(0, _url.IndexOf(API_DELIMETER));
            request.KeepAlive     = true;
            //request.Credentials = new NetworkCredential(txtUserName.Text, txtPass.Text);
            if (request.Method != "GET")
            {
                using (var stream = request.GetRequestStream())
                {
                    stream.Write(data, 0, data.Length);
                }
            }
            if (request.CookieContainer == null)
            {
                request.CookieContainer = new CookieContainer();
            }

            request = setCookies(request, _cookiesCollection);

            return(request);
        }
        private void removeRecord(int selectedId)
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + DELETE_CONVERSATION_API;

                ProspectClientConversation prosClientConv = new ProspectClientConversation()
                {
                    ID = selectedId,
                    ProspectClientId  = _prospectClient.ID,
                    MachineName       = System.Environment.MachineName,
                    UpdatedByUserName = Program.CurrentUser.UserName
                };

                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, "DELETE", DATA);

                if (json != null)
                {
                    var resultObject = jsonSerialization.DeserializeFromString <Result>(json);
                    if (resultObject.IsSuccess)
                    {
                        MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DataRow[] dr = _dtConversation.Select("ID =" + selectedId);
                        if (dr.Count() > 0)
                        {
                            dr[0].Delete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void removeRecord(TreeNode selectedNode)
        {
            try
            {
                FinancialPlanner.Common.JSONSerialization jsonSerialization = new FinancialPlanner.Common.JSONSerialization();
                string apiurl = Program.WebServiceUrl + "/" + DELETE_PROSPECT_CLIENTS_API;

                ProspectClient prospClient = convertSelectedRowDataToProspectCustomer();

                string DATA = jsonSerialization.SerializeToString <ProspectClient>(prospClient);

                WebClient client = new WebClient();
                client.Headers["Content-type"] = "application/json";
                client.Encoding = Encoding.UTF8;
                string json = client.UploadString(apiurl, "DELETE", DATA);

                if (json != null)
                {
                    var resultObject = jsonSerialization.DeserializeFromString <Result>(json);
                    if (resultObject.IsSuccess)
                    {
                        MessageBox.Show("Record deleted successfully.", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        trvList.SelectedNode.Remove();
                        DataRow[] dr = _dtProspClients.Select("ID =" + prospClient.ID);
                        if (dr.Count() > 0)
                        {
                            dr[0].Delete();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to delete record.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }