Ejemplo n.º 1
0
        private void user_acc_detail_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            //int counter = 0;
            
            ////////////////////////////////////////////////////////////////////////////////////////////////////////
            //show Account details
            try
            {
                var httpWebRequest3 = (HttpWebRequest)WebRequest.Create(GlobalClass.url + "/show_account_details/");
                httpWebRequest3.ContentType = "application/json";
                httpWebRequest3.Method = "POST";
                httpWebRequest3.CookieContainer = new CookieContainer();
                httpWebRequest3.CookieContainer.Add(new Uri(GlobalClass.url + "/show_account_details/"), new Cookie("sessionid", GlobalClass.session));
                
                //using (var streamWriter = new StreamWriter(httpWebRequest3.GetRequestStream()))
                //{
                //    string json = "{\"start_date\":" + GlobalClass.start_date + "," +
                //                      "\"end_date\":" + GlobalClass.end_date + "}";
                //    streamWriter.Write(json);
                //    streamWriter.Flush();
                //    streamWriter.Close();
                //}
                var httpResponse3 = (HttpWebResponse)httpWebRequest3.GetResponse();
                try
                {
                    dt.Columns.Add("ID");
                    dt.Columns.Add("Account Name");
                    dt.Columns.Add("Amount");
                    using (var streamReader3 = new StreamReader(httpResponse3.GetResponseStream()))
                    {
                        var result3 = streamReader3.ReadToEnd();
                        //MessageBox.Show(result3);
                        JObject obj = JObject.Parse(result3);

                        
                        //var data = "";

                        /*JToken accYr= (JToken)(obj["AccYearsList"][0]);
                        MessageBox.Show(Convert.ToString(accYr["start_date"]));*/
                        string str1 = (Convert.ToString(obj["accountList"]));
                        //MessageBox.Show(str1);
                        if(str1.Contains("[]"))
                        {
                            select_financial_yr financialYr = new select_financial_yr();
                            financialYr.MdiParent = this.MdiParent;
                            financialYr.Show();
                        }
                        else
                        {
                            mainForm.navPanel.Enabled = true;
                            mainForm.shortbtnPanel.Enabled = true;
                            int counter = 0;
                            //JToken accYr;
                            foreach (var ch in str1)
                            {
                                if (ch == '{')
                                    counter++;
                            }
                            //MessageBox.Show(Convert.ToString(counter));
                            if (counter > 0)
                            {
                                //MessageBox.Show(Convert.ToString(counter));
                                for (int i = 0; i < counter; i++)
                                {

                                    dt.Rows.Add(Convert.ToString((JToken)(obj["accountList"][i])["id"]), Convert.ToString((JToken)(obj["accountList"][i])["account_name"]), Convert.ToString((JToken)(obj["accountList"][i])["amount"]));
                                    dataGridView1.DataSource = dt;
                                }
                            }
                            else
                            {
                                MessageBox.Show("No Data found for your account");
                            }
                        }
                        

                    }
                }
                catch
                {
                    MessageBox.Show("No responce from server");
                }
            }
            catch
            {
                MessageBox.Show("Oops! Something went wrong.");
            }
            //duration.Text = (GlobalClass.start_date + GlobalClass.end_date);
            /*
            long int_data;
            DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
            DataTable dt = new DataTable();
            DateTime d, d1;
            */

        }
Ejemplo n.º 2
0
 private void button2_Click_1(object sender, EventArgs e)
 {
     select_financial_yr fy = new select_financial_yr();
     fy.Show();
 }
Ejemplo n.º 3
0
 private void reg_name_Enter(object sender, EventArgs e)
 {
     select_financial_yr fy = new select_financial_yr();
     fy.Show();
 }
Ejemplo n.º 4
0
 private void btnYrAdd_Click(object sender, EventArgs e)
 {
     while (ActiveMdiChild != null)
         ActiveMdiChild.Close();
     select_financial_yr addYr = new select_financial_yr();
     addYr.MdiParent = this;
     addYr.Show();
 }
Ejemplo n.º 5
0
        private void user_view_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            DateTime d,d1;

            //bool val1 = (System.Web.HttpContext.Current.User != null) && System.Web.HttpContext.Current.User.Identity.IsAuthenticated;
            
            //AuthenticationManager.Authenticate("",)
            try
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create(GlobalClass.url + "/list_of_accounting_years/");

                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method = "POST";
                httpWebRequest.CookieContainer = new CookieContainer();
                httpWebRequest.CookieContainer.Add(new Uri(GlobalClass.url + "/list_of_accounting_years/"), new Cookie("sessionid", GlobalClass.session));
                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    JObject obj = JObject.Parse(result);
                    dt.Columns.Add("Start Date");
                    dt.Columns.Add("End Date");
                    //var data = "";

                    /*JToken accYr= (JToken)(obj["AccYearsList"][0]);
                    MessageBox.Show(Convert.ToString(accYr["start_date"]));*/
                    string str1 = (Convert.ToString(obj["AccYearsList"]));
                    //MessageBox.Show(str1);
                    if (str1.Contains("[]"))
                    {
                        select_financial_yr selectFinYr = new select_financial_yr();
                        selectFinYr.MdiParent = this.MdiParent;
                        selectFinYr.Show();
                    }
                    else
                    {
                        mainForm.shortbtnPanel.Enabled = true;
                        mainForm.navPanel.Enabled = true;
                        int counter = 0;
                        //JToken accYr;
                        foreach (var ch in str1)
                        {
                            if (ch == '{')
                                counter++;
                        }
                        if (counter > 0)
                        {
                            for (int i = 0; i < counter; i++)
                            {

                                //accYr = (JToken)(obj["AccYearsList"][i]);
                                //MessageBox.Show(Convert.ToString(accYr["start_date"]));
                                //MessageBox.Show(Convert.ToString(accYr["end_date"]));
                                ////////////////////////////////////////////////////////////
                                //merged the value insted of variable if error then undo this
                                ////////////////////////////////////////////////////////////
                                //int_data = Int32.Parse(Convert.ToString((JToken)(obj["AccYearsList"][i])["start_date"]));
                                d = GlobalClass.origin.AddMilliseconds(Int64.Parse(Convert.ToString((JToken)(obj["AccYearsList"][i])["start_date"])));
                                //int_data = Int32.Parse(Convert.ToString((JToken)(obj["AccYearsList"][i])["end_date"]));
                                d1 = GlobalClass.origin.AddMilliseconds(Int64.Parse(Convert.ToString((JToken)(obj["AccYearsList"][i])["end_date"])));

                                //data = Convert.ToString(obj["AccYearsList"][++i]);
                                //data = Regex.Match(data, @"\d+").Value;
                                //int_data = Int32.Parse(data);
                                //d1 = origin.AddSeconds(int_data);

                                dt.Rows.Add(d.ToShortDateString(), d1.ToShortDateString());
                                dataGridView1.DataSource = dt;
                            }
                        }
                        else
                        {
                            MessageBox.Show("No Data found for your account");
                        }

                    }
                    
                }
            }
            catch
            {
                MessageBox.Show("Oops! Something went Wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }