Beispiel #1
0
 /// <summary>
 /// 保存表单(新增、修改)
 /// </summary>
 /// <param name="keyValue">主键值</param>
 /// <param name="entity">实体对象</param>
 /// <returns></returns>
 public void SaveForm(string keyValue, T_CapitalFlowEntity entity)
 {
     try
     {
         if (!string.IsNullOrEmpty(keyValue))
         {
             entity.Modify(keyValue);
             this.BaseRepository().Update(entity);
         }
         else
         {
             entity.Create();
             this.BaseRepository().Insert(entity);
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Beispiel #2
0
        public void SaveFormApp(List <FileModel> uploadFiles, List <T_CapitalFlow_NodeEntity> entity, string year, string month, string keyValue, string CapitalFlow_Title, string Job_Number)
        {
            try
            {
                IRepository         db       = new RepositoryFactory().BaseRepository().BeginTrans();
                T_CapitalFlowEntity cfEntity = new T_CapitalFlowEntity();
                if (!string.IsNullOrEmpty(keyValue))
                {
                    db.ExecuteBySql("update T_CapitalFlow_Node set DeleteMark=1 where CapitalFlow_Id='" + keyValue + "'");
                    cfEntity.Modify(keyValue);
                    cfEntity.Year              = int.Parse(year);
                    cfEntity.Month             = int.Parse(month);
                    cfEntity.Job_Number        = Job_Number;
                    cfEntity.CapitalFlow_Title = CapitalFlow_Title;
                    cfEntity.Account           = OperatorProvider.Provider.Current().Account;
                    cfEntity.ApprovalState     = 1;
                    if (entity != null)
                    {
                        cfEntity.Company_Id = entity[0].Company_Id;
                    }
                    this.BaseRepository().Update(cfEntity);
                }
                else
                {
                    cfEntity.Create();
                    cfEntity.CreateDate        = DateTime.Now;
                    cfEntity.DeleteMark        = 0;
                    cfEntity.Year              = int.Parse(year);
                    cfEntity.Month             = int.Parse(month);
                    cfEntity.Job_Number        = Job_Number;
                    cfEntity.CapitalFlow_Title = CapitalFlow_Title;
                    cfEntity.ApprovalState     = 1;
                    if (entity != null)
                    {
                        cfEntity.Company_Id = entity[0].Company_Id;
                    }
                    db.Insert(cfEntity);
                }

                try
                {
                    if (entity != null)
                    {
                        foreach (T_CapitalFlow_NodeEntity item in entity)
                        {
                            item.Create();
                            item.CapitalFlow_Id         = cfEntity.CapitalFlow_Id;
                            item.DeleteMark             = 0;
                            item.ClearingAmount         = item.ClearingAmount;
                            item.IncomeAmount           = item.IncomeAmount;
                            item.PlatformExpensesAmount = item.PlatformExpensesAmount;
                            item.CapitalPoolAdd         = item.CapitalPoolAdd;
                            item.Month = int.Parse(month);
                            item.Year  = int.Parse(year);
                            string upDate = string.Format("{0}-{1}", year, month);
                            item.UploadDate = Convert.ToDateTime(upDate);
                            db.Insert(item);
                        }
                    }
                    attservice.MapingFiles(cfEntity.CapitalFlow_Id, uploadFiles, db);
                    db.Commit();
                }
                catch (Exception)
                {
                    db.Rollback();
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Beispiel #3
0
        public string submitFormApp(List <FileModel> uploadFiles, List <T_CapitalFlow_NodeEntity> entity, string year, string month, string keyValue, string CapitalFlow_Title, string Job_Number)
        {
            try
            {
                //if (!string.IsNullOrEmpty(keyValue))
                //{
                //    entity.ApprovalState = 3;
                //    entity.Modify(keyValue);
                //    this.BaseRepository().Update(entity);
                //}
                //else
                //{
                //    entity.Create();
                //    entity.ApprovalState = 3;
                //    db.Insert(entity);
                ////}
                //var parameterFirst = new List<DbParameter>();
                //parameterFirst.Add(DbParameters.CreateDbParameter("@Company_Id", entity[0].Company_Id));
                //parameterFirst.Add(DbParameters.CreateDbParameter("@Year", year));
                //parameterFirst.Add(DbParameters.CreateDbParameter("@Month", month));

                //StringBuilder strSql = new StringBuilder();
                //strSql.Append("select CapitalFlow_Id from T_CapitalFlow  where Company_Id=@Company_Id and year=@Year and month=@Month and ApprovalState<>4");
                //IEnumerable<T_CapitalFlowEntity> newEntity = this.BaseRepository().FindList<T_CapitalFlowEntity>(strSql.ToString(), parameterFirst.ToArray());
                //if (newEntity.Count() != 0)
                //{
                //    foreach (T_CapitalFlowEntity t in newEntity) {
                //        this.BaseRepository().ExecuteBySql("update T_CapitalFlow_Node set DeleteMark=1 where CapitalFlow_Id='" + t.CapitalFlow_Id + "'");

                //    }
                //}

                IRepository db = new RepositoryFactory().BaseRepository().BeginTrans();



                T_CapitalFlowEntity cfEntity = new T_CapitalFlowEntity();
                if (!string.IsNullOrEmpty(keyValue))
                {
                    cfEntity.Company_Id        = entity[0].Company_Id;
                    cfEntity.DeleteMark        = 0;
                    cfEntity.Year              = int.Parse(year);
                    cfEntity.Month             = int.Parse(month);
                    cfEntity.CapitalFlow_Title = CapitalFlow_Title;
                    cfEntity.ApprovalState     = 1;
                    cfEntity.Account           = OperatorProvider.Provider.Current().Account;
                    cfEntity.Job_Number        = Job_Number;
                    cfEntity.Modify(keyValue);
                    this.BaseRepository().Update(cfEntity);
                    db.ExecuteBySql("update T_CapitalFlow_Node set DeleteMark=1 where CapitalFlow_Id= '" + keyValue + "'");
                }
                else
                {
                    cfEntity.Create();
                    cfEntity.CreateDate        = DateTime.Now;
                    cfEntity.DeleteMark        = 0;
                    cfEntity.Year              = int.Parse(year);
                    cfEntity.Job_Number        = Job_Number;
                    cfEntity.Month             = int.Parse(month);
                    cfEntity.CapitalFlow_Title = CapitalFlow_Title;
                    cfEntity.ApprovalState     = 1;
                    cfEntity.Company_Id        = entity[0].Company_Id;
                    db.Insert(cfEntity);
                }

                try
                {
                    foreach (T_CapitalFlow_NodeEntity item in entity)
                    {
                        item.Create();
                        item.CapitalFlow_Id         = cfEntity.CapitalFlow_Id;
                        item.DeleteMark             = 0;
                        item.ClearingAmount         = item.ClearingAmount;
                        item.IncomeAmount           = item.IncomeAmount;
                        item.PlatformExpensesAmount = item.PlatformExpensesAmount;
                        item.CapitalPoolAdd         = item.CapitalPoolAdd;
                        item.Month = int.Parse(month);
                        item.Year  = int.Parse(year);
                        string upDate = string.Format("{0}-{1}", year, month);
                        item.UploadDate = Convert.ToDateTime(upDate);
                        db.Insert(item);
                    }
                    attservice.MapingFiles(cfEntity.CapitalFlow_Id, uploadFiles, db);
                    db.Commit();
                    return(cfEntity.CapitalFlow_Id);
                }
                catch (Exception)
                {
                    db.Rollback();
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }