Exemplo 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();
 }
Exemplo 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);
        }
Exemplo n.º 3
0
        private void BindingForm(ApprovalModel model)
        {
            ClearBinding();
            txtRequestor.DataBindings.Add("Text", model, "RequestorId", false, DataSourceUpdateMode.OnPropertyChanged);
            txtDispatcherTeam.DataBindings.Add("Text", model, "DepatcherTeam", false, DataSourceUpdateMode.OnPropertyChanged);
            txtDispatcherRemark.DataBindings.Add("Text", model, "DispatcherRemark", false, DataSourceUpdateMode.OnPropertyChanged);
            txtReplyRemark.DataBindings.Add("Text", model, "ReplyRemark", false, DataSourceUpdateMode.OnPropertyChanged);

            if (model.ActionTreeId == 0)
            {
                if (reqHeadModel.RequestorID == epiSession.UserID)
                {
                    model.ActionTrees = _repo.GetStartTreeByUser(reqHeadModel.RequestorID).Where(x => x.TeamId.Equals(model.WaitForApproveTeamId)).ToList();

                    cboActionTree.Enabled = true;
                    rdoReject.Enabled     = false;
                    butBuyer.Visible      = false;
                }
                else
                {
                    MessageBox.Show("Requestor is not equal current user.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    this.Close();
                }
            }
            else
            {
                model.ActionTrees = _repo.GetAllGetStartTree().ToList();

                var resutl = _repo.GetTreeByID(model.ActionTreeId);
                model.ActionTree      = resutl.TreeViewName;
                cboActionTree.Enabled = false;
                rdoReject.Enabled     = true;
                butBuyer.Visible      = false;
            }

            if (model.ActionTrees.Count() != 0)
            {
                cboActionTree.DataSource    = model.ActionTrees;
                cboActionTree.DisplayMember = "TreeViewName";
                cboActionTree.ValueMember   = "TreeViewId";
                cboActionTree.DataBindings.Add("Text", model, "ActionTree");
            }
        }
Exemplo n.º 4
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);
            }
        }