Esempio n. 1
0
        protected void Operation_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    if (btn_AddTaxType.InnerText.Trim() == "Add")
                    {
                        using (var client = new HttpClient())
                        {
                            TaxTypeMaster p = new TaxTypeMaster
                            {
                                itemCode       = txt_itemCode.Value.ToString().Trim(),
                                taxCode        = txt_TaxCode.Value.ToString().Trim(),
                                taxDesc        = txt_TaxDesc.Value.ToString().Trim(),
                                taxRatePercent = txt_TaxPercent.Value.ToString().Trim(),
                                isactive       = chk_ActiveTaxType.Checked,
                                //  siteCode = txt_SiteCode.Value.ToString().Trim(),
                            };


                            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 <TaxTypeMaster>("api/TaxType1TaxCodes", p);
                            post.Wait();
                            var response = post.Result;


                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Tax Type 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())
                        {
                            TaxTypeMasterUpdate p = new TaxTypeMasterUpdate
                            {
                                id             = int.Parse(Session["id"].ToString()),
                                itemCode       = txt_itemCode.Value.ToString().Trim(),
                                taxCode        = txt_TaxCode.Value.ToString().Trim(),
                                taxDesc        = txt_TaxDesc.Value.ToString().Trim(),
                                taxRatePercent = txt_TaxPercent.Value.ToString().Trim(),
                                isactive       = chk_ActiveTaxType.Checked,
                                //  siteCode = txt_SiteCode.Value.ToString().Trim(),
                            };
                            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 <TaxTypeMasterUpdate>("api/TaxType1TaxCodes", p);
                            post.Wait();
                            var response = post.Result;

                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Tax Type 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_TaxType();
                }
            }
            catch (Exception Ex)
            {
                oCommonEngine.SetAlert(this.Page, Ex.Message, Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
            }
        }
Esempio n. 2
0
        protected void Operation_Click2(object sender, EventArgs e)
        {
            try
            {
                if (Validation2())
                {
                    if (btn_AddTaxType2.InnerText.Trim() == "Add")
                    {
                        using (var client = new HttpClient())
                        {
                            TaxTypeMaster p = new TaxTypeMaster
                            {
                                itemCode       = txt_itemCode2.Value.ToString().Trim(),
                                taxCode        = txt_TaxCode2.Value.ToString().Trim(),
                                taxDesc        = txt_TaxDesc2.Value.ToString().Trim(),
                                taxRatePercent = txt_TaxPercent2.Value.ToString().Trim(),
                                isactive       = chk_ActiveTaxType2.Checked
                                                 //  siteCode = txt_SiteCode.Value.ToString().Trim(),
                            };


                            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 <TaxTypeMaster>("api/TaxType2TaxCodes", p);
                            post.Wait();
                            var response = post.Result;


                            if (response.IsSuccessStatusCode)
                            {
                                ControlNosUpdate c = new ControlNosUpdate {
                                    controldescription = "2nd Tax Code", sitecode = System.Configuration.ConfigurationManager.AppSettings["SiteCode"].ToString(), controlnumber = Convert.ToString((Int64.Parse(Session["ControlNo_Tax2"].ToString()) + 1))
                                };
                                string api = "api/ControlNos/updatecontrol";
                                post = client.PostAsJsonAsync <ControlNosUpdate>(api, c);
                                post.Wait();
                                response = post.Result;
                                if (response.IsSuccessStatusCode)
                                {
                                    oCommonEngine.SetAlert(this.Page, "2nd Tax Code 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())
                        {
                            TaxTypeMasterUpdate p = new TaxTypeMasterUpdate
                            {
                                id             = int.Parse(Session["id"].ToString()),
                                itemCode       = txt_itemCode2.Value.ToString().Trim(),
                                taxCode        = txt_TaxCode2.Value.ToString().Trim(),
                                taxDesc        = txt_TaxDesc2.Value.ToString().Trim(),
                                taxRatePercent = txt_TaxPercent2.Value.ToString().Trim(),
                                isactive       = chk_ActiveTaxType2.Checked
                                                 //  siteCode = txt_SiteCode.Value.ToString().Trim(),
                            };
                            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 <TaxTypeMasterUpdate>("api/TaxType2TaxCodes", p);
                            post.Wait();
                            var response = post.Result;

                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "2nd Tax Code 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);
                            }
                        }
                    }

                    DataClear2();
                    Get_ControlPrefixs();
                    Get_1stTaxType();
                    Get_2ndTaxType();
                }
            }
            catch (Exception Ex)
            {
                oCommonEngine.SetAlert(this.Page, Ex.Message, Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
            }
        }