protected void Operation_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    if (btn_AddItemStatusGroups.InnerText.Trim() == "Add")
                    {
                        using (var client = new HttpClient())
                        {
                            ItemStatusGroups p = new ItemStatusGroups
                            {
                                statusGroupCode      = txt_StausCode.Value.ToString().Trim(),
                                statusGroupDesc      = txt_Desc.Value.ToString().Trim(),
                                statusGroupShortDesc = txt_ShortDesc.Value.ToString().Trim(),
                                isactive             = chkActive.Checked,
                            };


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


                            if (response.IsSuccessStatusCode)
                            {
                                ControlNosUpdate c = new ControlNosUpdate {
                                    controldescription = "Item Status Group", sitecode = System.Configuration.ConfigurationManager.AppSettings["SiteCode"].ToString(), controlnumber = Convert.ToString((Int64.Parse(Session["ControlNo"].ToString()) + 1))
                                };
                                string api = "api/ControlNos/updatecontrol";
                                post = client.PostAsJsonAsync <ControlNosUpdate>(api, c);
                                post.Wait();
                                response = post.Result;
                                if (response.IsSuccessStatusCode)
                                {
                                    txt_StausCode.Value = Session["Prefix"].ToString() + Convert.ToString((Int64.Parse(Session["ControlNo"].ToString()) + 1));
                                }

                                oCommonEngine.SetAlert(this.Page, "Item Status Groups Saved Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short);

                                CollapsiblePanelItemStatusGroupsList.Collapsed = false;
                                Get_ControlPrefixs();
                            }
                            else
                            {
                                oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
                            }
                        }
                    }
                    else
                    {
                        using (var client = new HttpClient())
                        {
                            ItemStatusGroupsUpdate p = new ItemStatusGroupsUpdate
                            {
                                id = int.Parse(Session["id"].ToString()),
                                statusGroupCode      = txt_StausCode.Value.ToString().Trim(),
                                statusGroupDesc      = txt_Desc.Value.ToString().Trim(),
                                statusGroupShortDesc = txt_ShortDesc.Value.ToString().Trim(),
                                isactive             = chkActive.Checked,
                            };
                            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 <ItemStatusGroupsUpdate>("api/ItemStatusGroups", p);
                            post.Wait();
                            var response = post.Result;

                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Item Status Groups 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);
                            }
                        }

                        Get_ControlPrefixs();
                    }

                    DataClear();
                    Get_ItemStatusGroups();
                }
            }
            catch (Exception Ex)
            {
                oCommonEngine.SetAlert(this.Page, Ex.Message, Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
            }
        }
Пример #2
0
        protected void Operation_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    if (btn_AddItemStatusGroups.InnerText.Trim() == "Add")
                    {
                        using (var client = new HttpClient())
                        {
                            ItemStatusGroups p = new ItemStatusGroups
                            {
                                statusGroupCode      = txt_StausCode.Value.ToString().Trim(),
                                statusGroupDesc      = txt_Desc.Value.ToString().Trim(),
                                statusGroupShortDesc = txt_ShortDesc.Value.ToString().Trim(),
                                isactive             = chkActive.Checked,
                            };


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


                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Item Status Groups Saved Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short);
                                //  Response.Redirect("ConfigInterface_PaymentType.aspx");
                                //   Get_BusinessHours();
                            }
                            else
                            {
                                oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
                            }
                        }
                    }
                    else
                    {
                        using (var client = new HttpClient())
                        {
                            ItemStatusGroupsUpdate p = new ItemStatusGroupsUpdate
                            {
                                id = int.Parse(Session["id"].ToString()),
                                statusGroupCode      = txt_StausCode.Value.ToString().Trim(),
                                statusGroupDesc      = txt_Desc.Value.ToString().Trim(),
                                statusGroupShortDesc = txt_ShortDesc.Value.ToString().Trim(),
                                isactive             = chkActive.Checked,
                            };
                            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 <ItemStatusGroupsUpdate>("api/ItemStatusGroups", p);
                            post.Wait();
                            var response = post.Result;

                            if (response.IsSuccessStatusCode)
                            {
                                oCommonEngine.SetAlert(this.Page, "Item Status Groups Updated Successfully..!", Utilities.CommonEngine.MessageType.Success, Utilities.CommonEngine.MessageDuration.Short);

                                //   Get_BusinessHours();
                            }
                            else
                            {
                                oCommonEngine.SetAlert(this.Page, response.StatusCode + "...!", Utilities.CommonEngine.MessageType.Error, Utilities.CommonEngine.MessageDuration.Short);
                            }
                        }
                    }

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