Exemple #1
0
        /// <summary>
        /// sWorkflowNo
        /// </summary>
        /// <param name="sWorkflowNo"></param>
        /// <param name="dt"></param>
        /// <returns></returns>
        string UpdatePAD(string sWorkflowNo, DataTable dt)
        {
            StringBuilder sbErrorInfo = new StringBuilder();
            foreach (DataRow dr in dt.Rows)
            {
                if (dr["NewPAD"] == null || dr["NewPAD"].ToString().Trim().Length == 0)
                {
                    continue;
                }
                string sPONO = dr["PONO"].ToString();
                string sPAD = dr["NewPAD"].ToString();

                SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
                if (!sapcommonpad.SapUpdatePAD(sPONO, Convert.ToDateTime(sPAD).ToString("yyyy-MM-dd")))
                {
                    sbErrorInfo.Append(string.Concat("Update ", sPONO, " to SAP failed,error info:", sapcommonpad.ErrorMsg.Replace("'", "‘").Replace("\n", "  "), "\\n"));
                }
                else
                {
                    UpdateItemPADState(sWorkflowNo, sPONO,true);
                }
            }
            return sbErrorInfo.ToString();
        }
Exemple #2
0
        /// <summary>
        /// 保存数据到SaveDataToPADChangeRequest
        /// </summary>
        /// <param name="sWorkflowNumber"></param>
        void SaveDataToPADChangeRequest(string sWorkflowNumber)
        {
            DataTable dtPADChangeRequest = CreatePADChangeTamplate();
            foreach (RepeaterItem item in RepeaterPOData.Items)
            {
                HiddenField HiddenFieldstoredelivery = item.FindControl("HiddenFieldstoredelivery") as HiddenField;
                if (HiddenFieldstoredelivery.Value == "True")
                {
                    continue;
                }
                Label LabelPONO = item.FindControl("LabelPONO") as Label;
                Label LabelPAD = item.FindControl("LabelPAD") as Label;
                CADateTimeControl CADateTimeFrom = item.FindControl("CADateTimeFrom") as CADateTimeControl;
                TextBox TextBoxSupplierName = item.FindControl("TextBoxSupplierName") as TextBox;
                TextBox TextBoxPADYear = item.FindControl("TextBoxPADYear") as TextBox;
                TextBox TextBoxPADweek = item.FindControl("TextBoxPADweek") as TextBox;
                TextBox TextBoxOSP = item.FindControl("TextBoxOSP") as TextBox;
                TextBox TextBoxValueForStory = item.FindControl("TextBoxValueForStory") as TextBox;
                TextBox TextBoxSADyear = item.FindControl("TextBoxSADyear") as TextBox;
                TextBox TextBoxSADweek = item.FindControl("TextBoxSADweek") as TextBox;
                TextBox TextBoxOMU = item.FindControl("TextBoxOMU") as TextBox;
                HiddenField HiddenFieldIsSuccess = item.FindControl("HiddenFieldIsSuccess") as HiddenField;
                TextBox TextBoxPOQTY = item.FindControl("TextBoxPOQTY") as TextBox;
                TextBox TextBoxStyleNO = item.FindControl("TextBoxStyleNO") as TextBox;

                DataRow dr = dtPADChangeRequest.NewRow();
                dr["Title"] = sWorkflowNumber;
                dr["PONumber"] = LabelPONO.Text.Trim();
                dr["CurrentPAD"] = LabelPAD.Text.Trim();
                dr["NewPAD"] = CADateTimeFrom.SelectedDate;
                dr["SupplierName"] = TextBoxSupplierName.Text.Trim();
                dr["PADyear"] = TextBoxPADYear.Text.Trim();
                dr["PADweek"] = TextBoxPADweek.Text.Trim();
                dr["OSP"] = TextBoxOSP.Text.Trim();
                dr["ValueForStory"] = TextBoxValueForStory.Text.Trim();
                dr["SADyear"] = TextBoxSADyear.Text.Trim();
                dr["SADweek"] = TextBoxSADweek.Text.Trim();
                dr["OMU"] = TextBoxOMU.Text.Trim();
                dr["IsSuccess"] = HiddenFieldIsSuccess.Value;
                dr["PoQty"] = TextBoxPOQTY.Text.Trim();
                dr["StyleNumber"] = TextBoxStyleNO.Text.Trim();

                dtPADChangeRequest.Rows.Add(dr);
            }

            SapCommonPADChangeRequest scpadcr = new SapCommonPADChangeRequest();
            scpadcr.BatchAddToListByDatatable(dtPADChangeRequest, "PADChangeRequestItems");
        }
Exemple #3
0
 /// <summary>
 /// 数据更新到SAP
 /// </summary>
 /// <param name="sWorkFlowNO"></param>
 /// <returns></returns>
 bool UpdateToSAP(string sWorkFlowNO)
 {
     bool isOK = true;
     StringBuilder sbErrorInfo = new StringBuilder();
     StringBuilder sbSucessInfo = new StringBuilder();
     foreach (RepeaterItem item in RepeaterPOData.Items)
     {
         HiddenField HiddenFieldstoredelivery = item.FindControl("HiddenFieldstoredelivery") as HiddenField;
         if (HiddenFieldstoredelivery.Value == "True")
         {
             continue;
         }
         Label LabelPAD = item.FindControl("LabelPAD") as Label;
         CADateTimeControl CADateTimeFrom = item.FindControl("CADateTimeFrom") as CADateTimeControl;
         HiddenField HiddenFieldIsSuccess = item.FindControl("HiddenFieldIsSuccess") as HiddenField;
         if (HiddenFieldIsSuccess.Value == "1")
         {
             continue;
         }
         if (Convert.ToDateTime(LabelPAD.Text.Trim()) < Convert.ToDateTime(CADateTimeFrom.SelectedDate))
         {
             Label LabelPONO = item.FindControl("LabelPONO") as Label;
             string sPONO = LabelPONO.Text.Trim();
             SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
             if (!sapcommonpad.SapUpdatePAD(LabelPONO.Text.ToString(), Convert.ToDateTime(CADateTimeFrom.SelectedDate).ToString("yyyy-MM-dd")))//更新到 SAP失败
             {
                 sbErrorInfo.Append(string.Concat("Update ", sPONO, " to SAP failed,error info:", sapcommonpad.ErrorMsg.Replace("'", "‘").Replace("\\n", "  "), "\\n"));
             }
             else
             {
                 sbSucessInfo.Append(string.Concat("\\nUpdate ", sPONO, " to SAP success"));
                 HiddenFieldIsSuccess.Value = "1";
                 sapcommonpad.UpdateItemSapStatus(sPONO, sWorkFlowNO);
                 CADateTimeFrom.Enabled = false;
             }
         }
     }
     if (sbErrorInfo.Length > 0)
     {
         sbErrorInfo.Append("\\nPlease contact IT form further help!");
         DisplayMessage(string.Concat("There are some errors occoured:\\n" + sbErrorInfo.ToString(), sbSucessInfo.ToString()));
         isOK = false;
     }
     return isOK;
 }
Exemple #4
0
        /// <summary>
        /// 从PO集合得到PO信息数据集
        /// </summary>
        /// <param name="dtPO"></param>
        /// <returns></returns>
        DataTable CreateSAPPOData(DataTable dtPO)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("PONumber");
            dt.Columns.Add("CurrentPAD");
            dt.Columns.Add("NewPAD");
            dt.Columns.Add("SupplierName");
            dt.Columns.Add("SADweek");
            dt.Columns.Add("SADyear");
            dt.Columns.Add("OMU");
            dt.Columns.Add("PADweek");
            dt.Columns.Add("PADyear");
            dt.Columns.Add("OSP");
            dt.Columns.Add("ValueForStory");
            dt.Columns.Add("IsNeedApprove");
            dt.Columns.Add("IsSuccess");
            dt.Columns.Add("PoQty");
            dt.Columns.Add("StyleNumber");

            //
            StringBuilder sb = new StringBuilder();
            foreach (DataRow drPO in dtPO.Rows)
            {
                SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
                string sPONO = drPO[0].ToString();
                string sNewPAD = drPO[1].ToString();
                if (sapcommonpad.SapSearchPAD(sPONO))
                {
                    DataRow dr = dt.NewRow();
                    dr["PONumber"] = sPONO;
                    dr["CurrentPAD"] = Convert.ToDateTime(sapcommonpad.PAD).ToString("MM\\/dd\\/yyyy");
                    dr["SupplierName"] = sapcommonpad.SupplierName;
                    dr["SADweek"] = sapcommonpad.SADweek;
                    dr["SADyear"] = sapcommonpad.SADyear;
                    dr["OMU"] = sapcommonpad.OMU;
                    dr["PADweek"] = sapcommonpad.PADweek;
                    dr["PADyear"] = sapcommonpad.PADyear;
                    dr["OSP"] = sapcommonpad.OSP;
                    dr["ValueForStory"] = sapcommonpad.ValueForStory;
                    dr["IsNeedApprove"] = sapcommonpad.Delivered;
                    dr["IsSuccess"] = 0;
                    dr["NewPAD"] = sNewPAD;
                    dr["PoQty"] = sapcommonpad.SPOQTY;
                    dr["StyleNumber"] = sapcommonpad.STYLENUMBER;

                    dt.Rows.Add(dr);
                }
                else
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("\\n");
                    }
                    sb.Append("Can not find ");
                    sb.Append(sPONO);
                }
            }
            if (sb.Length > 0)
            {
                DisplayMessage(sb.ToString());
            }

            return dt;
        }
        /// <summary>
        /// 数据更新到SAP
        /// </summary>
        /// <param name="sWorkFlowNO"></param>
        /// <returns></returns>
        bool UpdateToSAP(string sWorkFlowNO)
        {
            bool IsAllSeccuss = true;

            if (RepeaterPOData.Items.Count == 0)
            {
                return true;
            }

            StringBuilder sbErrorInfo = new StringBuilder();
            StringBuilder sbSucessInfo = new StringBuilder();
            foreach (RepeaterItem item in RepeaterPOData.Items)
            {
                Label LabelNewPAD = item.FindControl("LabelNewPAD") as Label;
                DropDownList DDLApproveStatus = item.FindControl("DDLApproveStatus") as DropDownList;

                if (DDLApproveStatus.SelectedValue == "1")
                {
                    Label LabelPONO = item.FindControl("LabelPONO") as Label;
                    string sPONO = LabelPONO.Text.Trim();
                    SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
                    HiddenField HiddenFieldIsSuccess = item.FindControl("HiddenFieldIsSuccess") as HiddenField;
                    if (HiddenFieldIsSuccess.Value == "1")
                    {
                        continue;
                    }
                    if (!sapcommonpad.SapUpdatePAD(LabelPONO.Text.ToString(), Convert.ToDateTime(LabelNewPAD.Text.Trim()).ToString("yyyy-MM-dd")))//更新到 SAP失败
                    {
                        IsAllSeccuss = false;
                        sbErrorInfo.Append(string.Concat("Update ", sPONO, " to SAP failed,error info:", sapcommonpad.ErrorMsg.Replace("'", "‘").Replace("\n", "  "), "\\n"));
                    }
                    else
                    {
                        sbSucessInfo.Append(string.Concat("\\nUpdate ", sPONO, " to SAP success"));
                        HiddenFieldIsSuccess.Value = "1";
                        bool isApprove = DDLApproveStatus.SelectedValue == "1" ? true : false;
                        sapcommonpad.UpdateItemSapStatus(sPONO, sWorkFlowNO);
                    }
                }
            }
            if (sbErrorInfo.Length > 0)
            {
                sbErrorInfo.Append("\\nPlease contact IT for further help!");
                DisplayMessage(string.Concat("There are some errors occoured:\\n" + sbErrorInfo.ToString(), sbSucessInfo.ToString()));
                CommonUtil.logError(sbErrorInfo.ToString());
            }
            UpdateItemApprove();
            return IsAllSeccuss;
        }
 /// <summary>
 /// 发送邮件
 /// </summary>
 /// <param name="sStatus"></param>
 void SendNoticeMail(string sStatus)
 {
     WorkflowDataFields fields = WorkflowContext.Current.DataFields;
     SapCommonPADChangeRequest comm=new SapCommonPADChangeRequest();
     try
     {
         comm.SendMail(WorkFlowUtil.GetApplicantAccount(fields["Applicant"].ToString()), sStatus, fields["Title"].ToString(), CurrentEmployee.UserAccount);// GetApprover(WorkFlowUtil.GetApplicantAccount(fields["Approvers"].ToString())));
     }
     catch(Exception e)
     {
         CommonUtil.logError("Sent PAD Mail failed:"+e.ToString());
     }
 }
        private void Actions_ActionExecuting(object sender, ActionEventArgs e)
        {
            SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
            WorkflowDataFields fields = WorkflowContext.Current.DataFields;
            string sWorkflowNumber = fields["Title"].ToString();
            switch (WorkflowContext.Current.Step)
            {
                case "ManagerApprove":
                    if (e.Action.Equals("Approve", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ///现审请者的manager为4,则结束流程
                        ///现审请者的manager为5,现审请者的manager的manager为4以上,则结束

                        bool isNeedBD = true;

                        Employee eCurrManager=UserProfileUtil.GetEmployeeEx(fields["CurrManager"].ToString());
                        int iCurrLevel = SapCommonPADChangeRequest.GetLevel(eCurrManager.JobLevel);

                        if (iCurrLevel == 4)//当前审批者的级别为4,不需要审批
                        {
                            isNeedBD = false;
                        }
                        else////当前审请者的级别为5
                        {
                           // QuickFlow.NameCollection BDMApprover = new QuickFlow.NameCollection();
                            Employee eBD = WorkFlowUtil.GetNextApprover(eCurrManager);
                            if (null == eBD)//当前审批者没有manager,不需要审批
                            {
                                isNeedBD = false;
                            }
                            else
                            {
                                int iLevel = SapCommonPADChangeRequest.GetLevel(eBD.JobLevel.AsString());
                                if (iLevel != 4)////当前审批者的manager不为4,不需要审批
                                {
                                    isNeedBD = false;
                                }

                            }
                        }
                        if (!isNeedBD)//不需要下一级审批
                        {
                            if (UpdateToSAP(sWorkflowNumber))
                            {
                                WorkflowContext.Current.UpdateWorkflowVariable("isOnlyApp", true);
                                WorkflowContext.Current.UpdateWorkflowVariable("updateResult", true);

                                //fields["CurrManager"] = WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString()))).UserAccount;
                                fields["Approvers"] = ReturnAllApprovers(fields["CurrManager"].ToString());
                                fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", fields["CurrManager"].ToString());
                                if (!SPContext.Current.Web.CurrentUser.LoginName.Equals(fields["CurrManager"].ToString(), StringComparison.CurrentCultureIgnoreCase))
                                {
                                    fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", SPContext.Current.Web.CurrentUser.LoginName);
                                }

                                fields["Status"] = CAWorkflowStatus.Completed;
                                SendNoticeMail("approved");
                            }
                            else
                            {
                                //DisplayMessage("更新SAP数据失败,请联系IT人员或稍后审批.Error:" + sapcommonpad.ErrorMsg.Replace("'", "‘").Replace("\\n", "  "));
                                e.Cancel = true;
                                return;
                            }
                        }
                        else///需要经过SuperManagerApprove审批
                        {
                            QuickFlow.NameCollection SuperApproveUser = new QuickFlow.NameCollection();
                            //var applicant = WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString());
                            Employee supmanagerEmp = WorkFlowUtil.GetNextApprover(eCurrManager);// WorkFlowUtil.GetApproverIgnoreRight(WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(applicant)));

                            if (supmanagerEmp == null)
                            {
                                DisplayMessage("此用户没有Level-4级审批用户,无法提交");
                                e.Cancel = true;
                                return;
                            }
                            SuperApproveUser.Add(supmanagerEmp.UserAccount);
                            var deleman = WorkFlowUtil.GetDeleman(supmanagerEmp.UserAccount, "127");
                            if (deleman != null)
                            {
                                SuperApproveUser.Add(deleman);
                            }
                            WorkflowContext.Current.UpdateWorkflowVariable("isOnlyApp", false);
                            WorkflowContext.Current.UpdateWorkflowVariable("secApproveU", SuperApproveUser);
                            WorkflowContext.Current.UpdateWorkflowVariable("SuperManagerT", "PAD Change Request needs to Approve");
                            WorkflowContext.Current.UpdateWorkflowVariable("approveUrl", "/_Layouts/CA/WorkFlows/PADChangeRequest/BatchApproveForm.aspx");

                            fields["Approvers"] = ReturnAllApprovers(fields["CurrManager"].ToString());
                            fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", fields["CurrManager"].ToString());
                            if (!SPContext.Current.Web.CurrentUser.LoginName.Equals(fields["CurrManager"].ToString(), StringComparison.CurrentCultureIgnoreCase))
                            {
                                fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", SPContext.Current.Web.CurrentUser.LoginName);
                            }
                            UpdateItemApprove();
                            fields["Status"] = CAWorkflowStatus.InProgress;
                            fields["CurrManager"] = supmanagerEmp.UserAccount;// WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString()))).UserAccount;
                        }
                    }
                    else//Reject
                    {
                        UpdateItemReject();
                       // fields["CurrManager"] = CurrentEmployee.UserAccount;// WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString()))).UserAccount;
                        fields["Status"] = CAWorkflowStatus.Completed;
                        fields["Approvers"] = ReturnAllApprovers(fields["CurrManager"].ToString());
                        fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", fields["CurrManager"].ToString());
                        SendNoticeMail("rejected");
                    }
                    break;
                case "SuperManagerApprove":
                    if (e.Action.Equals("Approve", StringComparison.CurrentCultureIgnoreCase))
                    {
                        if (UpdateToSAP(sWorkflowNumber))
                        {
                            WorkflowContext.Current.UpdateWorkflowVariable("updateResult", true);

                            var applicant = WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString());
                            var supmanagerEmp = WorkFlowUtil.GetApproverIgnoreRight(WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(applicant)));
                           // fields["CurrManager"] = supmanagerEmp.UserAccount;
                            fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", fields["CurrManager"].ToString());
                            if (!SPContext.Current.Web.CurrentUser.LoginName.Equals(fields["CurrManager"].ToString(), StringComparison.CurrentCultureIgnoreCase))
                            {
                                fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", SPContext.Current.Web.CurrentUser.LoginName);
                            }
                            fields["Status"] = CAWorkflowStatus.Completed;
                            SendNoticeMail("approved");
                        }
                        else
                        {
                            e.Cancel = true;
                            return;
                        }
                    }
                    else
                    {
                        UpdateItemReject();
                       // fields["CurrManager"] = CurrentEmployee.UserAccount;// WorkFlowUtil.GetApproverByLevelPAD(UserProfileUtil.GetEmployeeEx(WorkFlowUtil.GetApplicantAccount(WorkflowContext.Current.DataFields["Applicant"].ToString()))).UserAccount;
                        fields["Status"] = CAWorkflowStatus.Completed;
                        fields["Approvers"] = ReturnAllApprovers(fields["CurrManager"].ToString());
                        fields["ApproversSPUser"] = ReturnAllApproversSP("ApproversSPUser", fields["CurrManager"].ToString());
                        SendNoticeMail("rejected");
                    }
                    break;
            }

            WorkFlowUtil.UpdateWorkflowPath(WorkflowContext.Current);
        }
Exemple #8
0
        /// <summary>
        /// 从PO集合得到PO信息数据集
        /// </summary>
        /// <param name="dtPO"></param>
        /// <returns></returns>
        DataTable CreateSAPPOData(DataTable dtPO)
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("PONO");
            dt.Columns.Add("Date");
            dt.Columns.Add("PAD");
            dt.Columns.Add("SupplierName");
            dt.Columns.Add("SADweek");
            dt.Columns.Add("SADyear");
            dt.Columns.Add("OMU");
            dt.Columns.Add("PADweek");
            dt.Columns.Add("PADyear");
            dt.Columns.Add("OSP");
            dt.Columns.Add("ValueForStory");
            dt.Columns.Add("IsNeedApprove");
            dt.Columns.Add("IsSuccess");
            dt.Columns.Add("PoQty");
            dt.Columns.Add("StyleNumber");

            List<string> listStr = new List<string>();

            StringBuilder sb = new StringBuilder();
            foreach (DataRow drPO in dtPO.Rows)
            {
                string sPONO = drPO[0].ToString().Trim() ;///去重复
                if (listStr.Contains(sPONO))
                {
                    continue;
                }
                listStr.Add(sPONO);

                SapCommonPADChangeRequest sapcommonpad = new SapCommonPADChangeRequest();
                if (sapcommonpad.SapSearchPAD(sPONO))
                {
                    DataRow dr = dt.NewRow();
                    dr["PONO"] = sPONO.Trim();
                    dr["Date"] = drPO[1].ToString();
                    dr["PAD"] = Convert.ToDateTime(sapcommonpad.PAD).ToString("MM\\/dd\\/yyyy");
                    dr["SupplierName"] = sapcommonpad.SupplierName.Trim();
                    dr["SADweek"] = sapcommonpad.SADweek.Trim();
                    dr["SADyear"] = sapcommonpad.SADyear.Trim();
                    dr["OMU"] = sapcommonpad.OMU.Trim();
                    dr["PADweek"] = sapcommonpad.PADweek.Trim();
                    dr["PADyear"] = sapcommonpad.PADyear.Trim();
                    dr["OSP"] = sapcommonpad.OSP.Trim();
                    dr["ValueForStory"] = sapcommonpad.ValueForStory.Trim();
                    dr["IsNeedApprove"] = sapcommonpad.Delivered;
                    dr["IsSuccess"] = 0;
                    dr["PoQty"] = sapcommonpad.SPOQTY.Trim();

                    int iStyleNO = 0;
                    int.TryParse(sapcommonpad.STYLENUMBER,out iStyleNO);
                    dr["StyleNumber"] = iStyleNO.ToString();// sapcommonpad.STYLENUMBER;

                    dt.Rows.Add(dr);
                }
                else
                {
                    if (sb.Length > 0)
                    {
                        sb.Append("\\n");
                    }
                    sb.Append("Can not find ");
                    sb.Append(sPONO);
                }
            }
            if (sb.Length > 0)
            {
                DisplayMessage(sb.ToString());
            }
            return dt;
        }