Пример #1
0
 public static T_Agree ToModel(this  T_AgreeModel node)
 {
     return(new T_Agree()
     {
         Id = node.Id,
         AgreeDate = DateTime.Now,
         AgreeName = node.AgreeName,
         AgreeNo = node.AgreeNo,
         AgreeUserId = node.AgreeUserId,
         AgreeUserName = node.AgreeUserName,
         ApprovalUserId = node.ApprovalUserId,
         ApprovalUserIds = node.ApprovalUserIds,
         ApprovalUserName = node.ApprovalUserName,
         ApprovalUserNames = node.ApprovalUserNames,
         CostTotal = node.CostTotal,
         Discount = node.Discount,
         GrandTotal = node.GrandTotal,
         Gst = node.Gst,
         PriceTotal = node.PriceTotal,
         ProjectId = node.ProjectId,
         Status = node.Status,
         Remark = node.Remark,
         AgreeIndex = node.AgreeIndex,
     });
 }
Пример #2
0
        /// <summary>
        /// 复杂查询
        /// </summary>
        /// <param name="model">查询对象</param>
        /// <param name="Orders">排序字典key:排序的字段,value:asc升序/desc降序</param>
        /// <param name="PageSize">每页行数,默认15</param>
        /// <param name="PageIndex">当前页码,默认100</param>
        /// <returns></returns>
        public DataGrid <T_AgreeModel> Search(T_AgreeModel model, Dictionary <string, string> Orders = null, int PageSize = 15, int PageIndex = 100)
        {
            Expression <Func <T_Agree, bool> > where = null;                   //最终查询条件
            var lambdaList = new List <Expression <Func <T_Agree, bool> > >(); //lambda查询条件集合
            int total      = 0;                                                //总行数

            if (model.StatusList != null && model.StatusList.Count() > 0)
            {
                lambdaList.Add(c => model.StatusList.Any(a => c.Status == a));
            }
            if (model.ProjectId != null && model.ProjectId > 0)
            {
                lambdaList.Add(c => c.ProjectId == model.ProjectId);
            }
            //将集合表达式树转换成Expression表达式树
            MyVisitor <T_Agree, T_Agree> visitor = new MyVisitor <T_Agree, T_Agree>();

            where = visitor.Modify(lambdaList);
            var list   = dal.Search(out total, where, Orders, PageSize, PageIndex).DTOList().ToList();
            var result = new DataGrid <T_AgreeModel>()
            {
                rows  = list,
                total = total
            };

            return(result);
        }
Пример #3
0
        public static T_AgreeModel DTO(this T_Agree node)
        {
            if (node == null)
            {
                return(null);
            }
            var model = new T_AgreeModel()
            {
                Id                                      = node.Id,
                AgreeDate                               = node.AgreeDate,
                AgreeName                               = node.AgreeName,
                AgreeNo                                 = node.AgreeNo,
                AgreeUserId                             = node.AgreeUserId,
                AgreeUserName                           = node.AgreeUserName,
                ApprovalUserId                          = node.ApprovalUserId,
                ApprovalUserIds                         = node.ApprovalUserIds,
                ApprovalUserName                        = node.ApprovalUserName,
                ApprovalUserNames                       = node.ApprovalUserNames,
                CostTotal                               = node.CostTotal,
                Discount                                = node.Discount,
                GrandTotal                              = node.GrandTotal,
                Gst                                     = node.Gst,
                GstTotal                                = node.GstTotal,
                PriceTotal                              = node.PriceTotal,
                ProjectId                               = node.ProjectId,
                Status                                  = node.Status,
                Remark                                  = node.Remark,
                AgreeIndex                              = node.AgreeIndex,
                Project                                 = node.Project != null?node.Project.DTO() : null,
                                              AgreeList = node.AgreeList.Count() > 0 ? node.AgreeList.OrderBy(b => b.Category).Select(s => s.DTO()).ToList() : null,
            };

            return(model);
        }
Пример #4
0
        /// <summary>
        ///审批协议,这方法后面需要修改成事务。
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int ApporvalsProject(T_AgreeModel model)
        {
            int i = 0;
            int k = 0;
            //先获取
            var node = this.GetById(model.Id);

            if (model.Status == 1)
            {
                //先获得协议号,先看有没有获得过协议号
                // number = number + 55; // 字母A-Z编码在65-90
                int          AgreementNo = 0; //合同号
                int          index       = 0; //项目中的第几个合同
                T_CompanyBLL companybll  = new T_CompanyBLL();
                T_ProjectBLL projectbll  = new T_ProjectBLL();

                var projectnode = projectbll.GetById(model.ProjectId);

                T_Agree maxagree = dal.Filter(o => o.ProjectId == model.ProjectId && o.Status == 1).OrderByDescending(b => b.AgreeIndex).FirstOrDefault();
                if (maxagree != null)
                {
                    AgreementNo = maxagree.AgreeIndex > 0 ? int.Parse(maxagree.AgreeNo.Substring(0, maxagree.AgreeNo.Length - 1)) : int.Parse(maxagree.AgreeNo);
                    index       = int.Parse(maxagree.AgreeIndex.ToString()) + 1;
                }
                else
                {
                    T_Company company = companybll.GetById((int)projectnode.CompanyId);
                    AgreementNo         = (int)company.AgreementNo;
                    company.AgreementNo = AgreementNo + 1;
                    k = companybll.Edit(company);
                }
                if (projectnode != null)
                {
                    projectnode.Status = 1;
                    k = projectbll.Edit(projectnode);
                }

                if (node != null)
                {
                    node.Status     = model.Status;
                    node.AgreeDate  = DateTime.Now;
                    node.AgreeIndex = index;
                    node.AgreeNo    = index == 0 ? AgreementNo.ToString() : AgreementNo.ToString() + Helper.Method.Chr(64 + index);
                    i = this.Edit(node);
                }
            }
            else
            {
                if (node != null)
                {
                    node.Status    = model.Status;
                    node.AgreeDate = DateTime.Now;
                    i = this.Edit(node);
                }
            }



            return(i);
        }
Пример #5
0
        /// <summary>
        /// 签署协议,这方法后面需要修改成事务。
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int AgreeProject(T_AgreeModel model)
        {
            int i = 0;
            int k = 0;
            //先获取
            var node = this.GetById(model.Id);

            if (node != null)
            {
                node.CostTotal  = model.CostTotal;
                node.PriceTotal = model.PriceTotal;
                node.Discount   = model.Discount;
                node.Gst        = model.Gst;
                node.GstTotal   = model.GstTotal;
                node.Status     = model.Status;
                node.GrandTotal = model.GrandTotal;
                i = this.Edit(node);
            }
            //T_ProjectBLL project=new T_ProjectBLL();

            //var projectnode = project.GetById(model.ProjectId);
            //if (projectnode != null)
            //{
            //    projectnode.State =1;
            //    k = project.Edit(projectnode);
            //}

            return(i);
        }
Пример #6
0
        public int AddData(T_AgreeModel model)
        {
            T_Agree node = new T_Agree()
            {
                AgreeDate  = DateTime.Now,
                AgreeName  = model.AgreeName,
                ProjectId  = model.ProjectId,
                Status     = 0,
                AgreeIndex = 100,
                Remark     = model.Remark,
            };

            return(this.Add(node));
        }
Пример #7
0
        public int EditData(T_AgreeModel model)
        {
            int i = 0;
            //先获取
            var node = this.GetById(model.Id);

            if (node != null)
            {
                node.AgreeDate = DateTime.Now;
                node.AgreeName = model.AgreeName;
                node.Remark    = model.Remark;
                i = this.Edit(node);
            }

            return(i);
        }
Пример #8
0
 /// <summary>
 /// 根据对象中的主键Id删除
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int DeleteData(T_AgreeModel model)
 {
     return(this.Delete(model.Id));
 }