예제 #1
0
        private void FetchRecords()
        {
            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                string api      = "api/PayGroups/" + _PKey;
                var    response = client.GetAsync(api).Result;
                if (response.IsSuccessStatusCode)
                {
                    var            a = response.Content.ReadAsStringAsync().Result;
                    PayGroupUpdate payGroupUpdate = JsonConvert.DeserializeObject <PayGroupUpdate>(a);

                    txtCode_PayGroup.Value = payGroupUpdate.payGroupCode;
                    txtSqe_PayGroup.Value  = Convert.ToString(payGroupUpdate.seq);
                }
                else
                {
                    Console.WriteLine("Internal server Error");
                }
            }
        }
예제 #2
0
        protected void Operation_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    if (btn_AddPayGroup.InnerText.Trim() == "Add")
                    {
                        using (var client = new HttpClient())
                        {
                            PayGroup p = new PayGroup
                            {
                                payGroupCode = txtCode_PayGroup.Value.ToString().Trim(),
                                seq          = Int32.Parse(txtSqe_PayGroup.Value),
                                iscreditcard = null,
                                // imgUpload = img_Upload.Value.ToString()
                            };



                            //FileUpload img = (FileUpload)img_Upload;
                            //Byte[] imgByte = null;
                            //if (img.HasFile && img.PostedFile != null)
                            //{
                            //    img_Upload imgByte = new Byte[File.ContentLength];
                            //    File.InputStream.Read(imgByte, 0, File.ContentLength);
                            //}
                            //string conn = ConfigurationManager.ConnectionStrings["EmployeeConnString"].ConnectionString;
                            //connection = new SqlConnection(conn);

                            //connection.Open();
                            //string sql = "INSERT INTO EmpDetails(empname,empimg) VALUES(@enm, @eimg) SELECT @@IDENTITY";
                            //SqlCommand cmd = new SqlCommand(sql, connection);
                            //cmd.Parameters.AddWithValue("@enm", txtEName.Text.Trim());
                            //cmd.Parameters.AddWithValue("@eimg", imgByte);
                            //int id = Convert.ToInt32(cmd.ExecuteScalar());
                            //lblImageName.Text = String.Format("Employee ID is {0}", id);


                            client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]);
                            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                            var post = client.PostAsJsonAsync <PayGroup>("api/PayGroups", p);
                            post.Wait();
                            var response = post.Result;


                            if (response.IsSuccessStatusCode)
                            {
                                //ControlNosUpdate c = new ControlNosUpdate { controldescription = "Room Code", controlnumber = Convert.ToString((Int64.Parse(txtCode_Room.Value.ToString()) + 1)) };
                                //string api = "api/ControlNos/updatecontrol";
                                //post = client.PostAsJsonAsync<ControlNosUpdate>(api, c);
                                //post.Wait();
                                //response = post.Result;
                                //if (response.IsSuccessStatusCode)
                                //{
                                //    txtCode_Room.Value = Convert.ToString((Int64.Parse(txtCode_Room.Value.ToString()) + 1));
                                //}
                                oCommonEngine.SetAlert(this.Page, "Payment Group Saved Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short);
                            }
                            else
                            {
                                oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
                            }
                        }
                    }
                    else
                    {
                        using (var client = new HttpClient())
                        {
                            PayGroupUpdate p = new PayGroupUpdate
                            {
                                id           = Int32.Parse(_PKey),
                                payGroupCode = txtCode_PayGroup.Value.ToString().Trim(),
                                seq          = Int32.Parse(txtSqe_PayGroup.Value),
                                iscreditcard = null
                            };
                            client.BaseAddress = new Uri(System.Configuration.ConfigurationManager.AppSettings["uri"]);
                            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                            var post = client.PutAsJsonAsync <PayGroupUpdate>("api/PayGroups", p);
                            post.Wait();
                            var response = post.Result;

                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Payment Group Updated Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short);
                            }
                            else
                            {
                                oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
                            }
                        }
                    }

                    DataClear();
                    Get_PayGroups();
                }
            }
            catch (Exception Ex)
            {
                oCommonEngine.SetAlert(this.Page, Ex.Message, Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
            }
        }