Exemplo n.º 1
0
        public static string WMSaveApproval(long RequestID, string ApprovalStatus, long APL, string ApprovalRemark, string InvoiceNo)
        {
            iPartRequestClient objService = new iPartRequestClient();
            string             result     = "";

            try
            {
                CustomProfile profile = CustomProfile.GetProfile();

                if (ApprovalStatus == "3")
                {
                    objService.UpdatetApprovalTransAfterApproval(APL, RequestID, 3, ApprovalRemark, profile.Personal.UserID, InvoiceNo, profile.DBConnection._constr);
                    result = "true";
                }
                else if (ApprovalStatus == "4")
                {
                    objService.UpdatetApprovalTransAfterReject(APL, RequestID, 4, ApprovalRemark, profile.Personal.UserID, profile.DBConnection._constr);
                    result = "true";
                }
                else if (ApprovalStatus == "24")
                {
                    objService.UpdatetApprovalTransAfterApproval(0, RequestID, 24, ApprovalRemark, profile.Personal.UserID, "0", profile.DBConnection._constr);
                    result = "truerev";
                }
            }
            catch { }
            finally
            { objService.Close(); }
            return(result);
        }
        public void ProcessRequest(HttpContext context)
        {
            SqlConnection conn = new SqlConnection(strcon);

            long   aprId  = Convert.ToInt64(context.Request.Form["aprId"]);
            string OdrID  = context.Request.Form["reqId"];
            String reqAct = context.Request.Form["reqAct"];

            SqlCommand     cmd3 = new SqlCommand();
            SqlDataAdapter da3  = new SqlDataAdapter();
            DataTable      dt3  = new DataTable();
            DataSet        ds3  = new DataSet();

            cmd3.CommandType = CommandType.Text;
            cmd3.CommandText = "select Id from tOrderHead where OrderNo='" + OdrID + "'";
            cmd3.Connection  = conn;
            cmd3.Parameters.Clear();
            //cmd.Parameters.AddWithValue("param1", ResourceId);
            da3.SelectCommand = cmd3;
            da3.Fill(ds3, "tbl4");
            dt3 = ds3.Tables[0];

            long reqId = Convert.ToInt32(dt3.Rows[0]["Id"].ToString());


            long statusId = 0;

            if (reqAct == "Approved")
            {
                statusId = 3;
            }
            else if (reqAct == "Rejected")
            {
                statusId = 4;
            }

            string reqRemark   = context.Request.Form["reqRemark"];
            string aprUserName = context.Request.Form["aprUserName"];
            string InvNo       = "";

            InvNo = context.Request.Form["reqInvoiceNo"];

            CustomProfile profile = CustomProfile.GetProfile(aprUserName);


            String xmlString = String.Empty;

            context.Response.ContentType = "text/xml";
            xmlString = xmlString + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
            xmlString = xmlString + "<gwcInfo>";
            xmlString = xmlString + "<approvalAction>";

            iPartRequestClient objService = new iPartRequestClient();

            try
            {
                SqlCommand     cmd1 = new SqlCommand();
                SqlDataAdapter da1  = new SqlDataAdapter();
                DataTable      dt1  = new DataTable();
                DataSet        ds1  = new DataSet();
                cmd1.Connection   = conn;
                cmd1.CommandType  = CommandType.Text;
                cmd1.CommandText  = "select * from VW_ApprovalTransDetails where OrderID=" + reqId + " and approverID=" + aprId + " and Status !=3";
                da1.SelectCommand = cmd1;
                da1.Fill(ds1, "dtl");
                dt1 = ds1.Tables[0];
                if (dt1.Rows.Count > 0)
                {
                    long aprovalid = Convert.ToInt64(dt1.Rows[0]["ApprovalID"].ToString());
                    if (statusId == 3)
                    {
                        objService.UpdatetApprovalTransAfterApproval(aprovalid, reqId, statusId, CheckString(reqRemark), aprId, InvNo, profile.DBConnection._constr);
                    }
                    else if (statusId == 4)
                    {
                        objService.UpdatetApprovalTransAfterReject(aprovalid, reqId, statusId, CheckString(reqRemark), aprId, profile.DBConnection._constr);
                    }
                    xmlString = xmlString + "<authmsg>success</authmsg>";
                }
            }
            catch { xmlString = xmlString + "<authmsg>failed</authmsg>"; }

            xmlString = xmlString + "</approvalAction>";
            xmlString = xmlString + "</gwcInfo>";

            context.Response.Write(xmlString);
        }