Ejemplo n.º 1
0
 public Approval(Ice.Core.Session _session = null, ApprovalModel model = null, ReqHeadModel reqHead = null)
 {
     InitializeComponent();
     epiSession        = _session;
     this.content      = model;
     this.reqHeadModel = reqHead;
     this._repo        = new AuthRepo();
     this._repoReq     = new RequisitionRepo();
 }
Ejemplo n.º 2
0
        private void butDispatch_Click(object sender, EventArgs e)
        {
            ReqHeadModel  reqHead = new ReqHeadModel();
            ApprovalModel model   = new ApprovalModel();

            model.OrderNum             = dgvList.CurrentRow.Cells["requisition"].Value.ToString().Trim();
            model.ActionTreeId         = Convert.ToInt32(dgvList.CurrentRow.Cells["treeviewid"].Value);
            model.WaitForApproveTeamId = dgvList.CurrentRow.Cells["actionteam"].Value.ToString();
            model.DispatcherRemark     = dgvList.CurrentRow.Cells["remark"].Value.ToString();

            reqHead = _repo.GetByID(Convert.ToInt32(model.OrderNum));

            using (Approval frm = new Approval(epiSession, model, reqHead))
            {
                frm.ShowDialog();
            }

            PRList_Load(sender, e);
        }
Ejemplo n.º 3
0
        public bool SaveApprove(CustomSession _session, ApprovalModel model, ReqHeadModel reqHead)
        {
            var result = GetByID(Convert.ToInt32(model.OrderNum));

            string sql = string.Format(@"UPDATE ReqHead
                                           SET  Status_c = '{1}'
                                              , TreeViewID_c = N'{2}'
                                              , WaitingTeamID_c = N'{3}'
	                                          , ReqActionDesc_c = N'{4}'
                                              , SentByTeam_c = N'{5}'
                                         WHERE ReqNum = {0}" + Environment.NewLine
                                       , model.OrderNum
                                       , model.ApproveFlag == true ? "2" : "3"
                                       , model.ActionTreeId
                                       , model.ApproveFlag == true ? model.DepatcherTeam : result.SentByTeam
                                       , model.ReplyRemark
                                       , model.ApproveFlag == true ? model.WaitForApproveTeamId : "");

            try
            {
                Repository.Instance.ExecuteWithTransaction(sql, "Approve");

                var lv = _repoAth.GetAllTeamsLevel().Where(x => x.TreeViewId.Equals(model.ActionTreeId) && x.TeamId.Equals(model.WaitForApproveTeamId)).OrderByDescending(i => i.Level).FirstOrDefault();
                if (lv.Level == 0)
                {
                    string resultMessage;
                    reqHead.ReqNum         = Convert.ToInt32(model.OrderNum);
                    reqHead.NextActionID   = "03";
                    reqHead.NextActionDesc = "Purchasing Department";
                    reqHead.ReplyOption    = "A";
                    reqHead.ReqUserId      = reqHead.RequestorID;

                    SendToPOSuggestions(_session, reqHead, out resultMessage);
                    UpdateBuyer(reqHead.ReqNum, model.DepatcherTeam);
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public bool SendToPOSuggestions(CustomSession _session, ReqHeadModel model, out string resultMessage)
        {
            Erp.Custom.Core.Session.EndpointBindingSvc.EndpointBindingType bindingType;
            resultMessage = string.Empty;
            bool       result  = false;
            UriBuilder builder = _inst.EndpointBinding(out bindingType);
            SessionModSvcContractClient sessionModClient = _inst.IdentifiesSession(_session);

            builder.Path = _inst.epiSite + "/Erp/BO/Req.svc";
            ReqSvcContractClient reqClient = _inst.GetClient <ReqSvcContractClient, ReqSvcContract>(builder.Uri.ToString(), _session.UserId, _session.Password, bindingType);

            Guid sessionId = Guid.Empty;

            try
            {
                sessionId = sessionModClient.Login();
                sessionModClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, _session.UserId));
                reqClient.Endpoint.Behaviors.Add(new HookServiceBehavior(sessionId, _session.UserId));
                var ts = new Erp.Custom.Core.Session.Epicor.ReqSvc.ReqTableset();
                ts = reqClient.GetByID(model.ReqNum);

                if (ts != null && ts.ReqHead.Any())
                {
                    Erp.Custom.Core.Session.Epicor.ReqSvc.ReqHeadRow backupRow = new Erp.Custom.Core.Session.Epicor.ReqSvc.ReqHeadRow();
                    var fields = backupRow.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
                    foreach (var field in fields)
                    {
                        if (field.PropertyType == typeof(System.Runtime.Serialization.ExtensionDataObject))
                        {
                            continue;
                        }

                        var fieldValue = field.GetValue(ts.ReqHead[0]);
                        field.SetValue(backupRow, fieldValue);
                    }
                    ts.ReqHead.Add(backupRow);
                }

                ts.ReqHead[0].NextActionID   = model.NextActionID;   //"03";
                ts.ReqHead[0].NextActionDesc = model.NextActionDesc; //"Send to Procurement Dept";
                ts.ReqHead[0].ReplyOption    = model.ReplyOption;    //"A";
                ts.ReqHead[0].ReqUserId      = model.ReqUserId;      //"Manager";
                ts.ReqHead[0].RowMod         = "U";

                try
                {
                    reqClient.Update(ref ts);
                    result = true;
                }
                catch (FaultException <Erp.Custom.Core.Session.Epicor.ReqSvc.EpicorFaultDetail> ex)
                {
                    if (ex.Detail.ExceptionKindValue.Equals("RecordNotFound", StringComparison.InvariantCultureIgnoreCase))
                    {
                        resultMessage = "Record deleted.";
                    }
                    else
                    {
                        resultMessage = ex.Message;
                    }
                }
            }
            catch (Exception ex)
            {
                resultMessage = "ex" + ex.Message;
                sessionModClient.Logout();
                return(result);
            }

            return(result);
        }