コード例 #1
0
ファイル: ItemRequest_Items.cs プロジェクト: laikamanor/pos
        public void forUpdatingSAP()
        {
            string      URL         = "/api/inv/item_request/sap_update/" + selectedID;
            SAP_Remarks sAP_Remarks = new SAP_Remarks();

            sAP_Remarks.ShowDialog();
            if (SAP_Remarks.isSubmit)
            {
                string  remarks     = SAP_Remarks.rem;
                int     sapNumber   = SAP_Remarks.sap_number;
                JObject jObjectBody = new JObject();
                jObjectBody.Add("sap_number", sapNumber);
                jObjectBody.Add("remarks", remarks);
                apiPUT(jObjectBody, URL);
            }
        }
コード例 #2
0
 private void btnUpdateSAP_Click(object sender, EventArgs e)
 {
     if (this.Text == "Adjustment In Details")
     {
         if (gAdjTrans.Equals("For SAP"))
         {
             SAP_Remarks sapRemarks = new SAP_Remarks();
             sapRemarks.isOptional = false;
             sapRemarks.ShowDialog();
             int    sapNumber = SAP_Remarks.sap_number;
             string remarks   = SAP_Remarks.rem;
             if (SAP_Remarks.isSubmit)
             {
                 JObject jObjectBody = new JObject();
                 JArray  jArrayID    = new JArray();
                 jArrayID.Add(selectedID);
                 jObjectBody.Add("ids", jArrayID);
                 jObjectBody.Add("sap_number", sapNumber);
                 jObjectBody.Add("remarks", remarks);
                 apiPUT(jObjectBody, "/api/sap_num/adj_in/update");
                 if (isSubmit)
                 {
                     this.Dispose();
                 }
             }
         }
         else
         {
             MessageBox.Show("Access Denied", "Validation", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Access Denied", "Validation", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
ファイル: SelectedItem.cs プロジェクト: laikamanor/pos
        private void btnProceed_Click(object sender, EventArgs e)
        {
            if (dgv.Rows.Count > 0)
            {
                SAP_Remarks sAP_Remarks = new SAP_Remarks();
                sAP_Remarks.isOptional = true;
                sAP_Remarks.ShowDialog();
                if (SAP_Remarks.isSubmit)
                {
                    int    sap_number = SAP_Remarks.sap_number;
                    string remarks    = SAP_Remarks.rem;
                    Cursor.Current = Cursors.WaitCursor;
                    if (Login.jsonResult != null)
                    {
                        string token = "";
                        foreach (var x in Login.jsonResult)
                        {
                            if (x.Key.Equals("token"))
                            {
                                token = x.Value.ToString();
                            }
                        }
                        if (!token.Equals(""))
                        {
                            var client = new RestClient(utilityc.URL);
                            client.Timeout = -1;
                            var request = new RestRequest("/api/inv_adj/" + gAdjType + "/new");
                            //MessageBox.Show("/api/inv_adj/" + gAdjType + "/new");
                            request.AddHeader("Authorization", "Bearer " + token);
                            request.Method = Method.POST;
                            JObject jObjectBody   = new JObject();
                            JArray  jArrayRows    = new JArray();
                            JObject jObjectHeader = new JObject();
                            jObjectHeader.Add("transdate", DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                            if (sap_number <= 0)
                            {
                                jObjectHeader.Add("sap_number", null);
                            }
                            else
                            {
                                jObjectHeader.Add("sap_number", sap_number);
                            }
                            jObjectHeader.Add("remarks", remarks);
                            jObjectBody.Add("header", jObjectHeader);
                            if (dgv.Rows.Count > 0)
                            {
                                for (int i = 0; i < dgv.Rows.Count; i++)
                                {
                                    JObject jObjectRows = new JObject();
                                    string  itemCode    = dgv.Rows[i].Cells["item_code"].Value.ToString();
                                    double  quantity    = Convert.ToDouble(dgv.Rows[i].Cells["quantity"].Value.ToString());
                                    string  uom         = dgv.Rows[i].Cells["uom"].Value.ToString();
                                    jObjectRows.Add("item_code", itemCode);
                                    jObjectRows.Add("quantity", quantity);
                                    jObjectRows.Add("uom", uom);
                                    jArrayRows.Add(jObjectRows);
                                }
                                jObjectBody.Add("rows", jArrayRows);
                                request.AddParameter("application/json", jObjectBody, ParameterType.RequestBody);
                                var response = client.Execute(request);
                                if (response.Content.ToString().Substring(0, 1).Equals("{"))
                                {
                                    JObject jObjectResponse = JObject.Parse(response.Content);
                                    bool    isSuccess       = false;
                                    foreach (var x in jObjectResponse)
                                    {
                                        if (x.Key.Equals("success"))
                                        {
                                            isSuccess = Convert.ToBoolean(x.Value.ToString());
                                        }
                                    }

                                    if (isSuccess)
                                    {
                                        string msg = "Object message key not found";
                                        foreach (var x in jObjectResponse)
                                        {
                                            if (x.Key.Equals("message"))
                                            {
                                                msg = x.Value.ToString();
                                            }
                                        }
                                        Cursor.Current = Cursors.Default;
                                        MessageBox.Show(msg, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                        this.Hide();
                                    }
                                    else
                                    {
                                        string msg = "Object message key not found";
                                        foreach (var x in jObjectResponse)
                                        {
                                            if (x.Key.Equals("message"))
                                            {
                                                msg = x.Value.ToString();
                                            }
                                        }
                                        if (msg.Equals("Token is invalid"))
                                        {
                                            Cursor.Current = Cursors.Default;
                                            MessageBox.Show("Your login session is expired. Please login again", "Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                        else
                                        {
                                            Cursor.Current = Cursors.Default;
                                            MessageBox.Show(msg, "Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                        }
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(response.Content.ToString(), "Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("No data selected", "Validation", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }