Exemplo n.º 1
0
        public ResultModel Load(UserModel user,int allotId,NFMT.Common.StatusEnum status = NFMT.Common.StatusEnum.已生效)
        {
            ResultModel result = new ResultModel();
            try
            {
                string cmdText = string.Format("select crr.* from dbo.Fun_CorpReceivable_Ref crr inner join dbo.Fun_RecAllotDetail rad on crr.DetailId = crr.DetailId and rad.DetailStatus>={0} where crr.AllotId ={1}",(int)status,allotId);
                DataTable dt = SqlHelper.ExecuteDataTable(ConnectString,cmdText, null, CommandType.Text);

                List<CorpReceivable> corpReceivables = new List<CorpReceivable>();

                foreach (DataRow dr in dt.Rows)
                {
                    CorpReceivable corpreceivable = new CorpReceivable();
                    corpreceivable.RefId = Convert.ToInt32(dr["RefId"]);

                    if (dr["AllotId"] != DBNull.Value)
                    {
                        corpreceivable.AllotId = Convert.ToInt32(dr["AllotId"]);
                    }
                    if (dr["DetailId"] != DBNull.Value)
                    {
                        corpreceivable.DetailId = Convert.ToInt32(dr["DetailId"]);
                    }
                    if (dr["BlocId"] != DBNull.Value)
                    {
                        corpreceivable.BlocId = Convert.ToInt32(dr["BlocId"]);
                    }
                    if (dr["CorpId"] != DBNull.Value)
                    {
                        corpreceivable.CorpId = Convert.ToInt32(dr["CorpId"]);
                    }
                    if (dr["RecId"] != DBNull.Value)
                    {
                        corpreceivable.RecId = Convert.ToInt32(dr["RecId"]);
                    }
                    if (dr["IsShare"] != DBNull.Value)
                    {
                        corpreceivable.IsShare = Convert.ToBoolean(dr["IsShare"]);
                    }
                    corpReceivables.Add(corpreceivable);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = corpReceivables;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 2
0
        public ResultModel GetCorpReceivableByAllotId(UserModel user, int allotId)
        {
            ResultModel result = new ResultModel();

            try
            {
                string sql = string.Format("select * from Fun_CorpReceivable_Ref where AllotId = {0} and RefStatus = {1}", allotId, (int)Common.StatusEnum.已生效);
                DataTable dt = NFMT.DBUtility.SqlHelper.ExecuteDataTable(this.ConnectString, sql, null, CommandType.Text);
                if (dt != null && dt.Rows.Count > 0)
                {
                    List<CorpReceivable> corpReceivables = new List<CorpReceivable>();

                    foreach (DataRow dr in dt.Rows)
                    {
                        CorpReceivable corpreceivable = new CorpReceivable();
                        corpreceivable.RefId = Convert.ToInt32(dr["RefId"]);

                        if (dr["AllotId"] != DBNull.Value)
                        {
                            corpreceivable.AllotId = Convert.ToInt32(dr["AllotId"]);
                        }
                        if (dr["DetailId"] != DBNull.Value)
                        {
                            corpreceivable.DetailId = Convert.ToInt32(dr["DetailId"]);
                        }
                        if (dr["BlocId"] != DBNull.Value)
                        {
                            corpreceivable.BlocId = Convert.ToInt32(dr["BlocId"]);
                        }
                        if (dr["CorpId"] != DBNull.Value)
                        {
                            corpreceivable.CorpId = Convert.ToInt32(dr["CorpId"]);
                        }
                        if (dr["RecId"] != DBNull.Value)
                        {
                            corpreceivable.RecId = Convert.ToInt32(dr["RecId"]);
                        }
                        if (dr["IsShare"] != DBNull.Value)
                        {
                            corpreceivable.IsShare = Convert.ToBoolean(dr["IsShare"]);
                        }
                        corpReceivables.Add(corpreceivable);
                    }
                    result.AffectCount = dt.Rows.Count;
                    result.Message = "获取列表成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = corpReceivables;
                }
                else
                {
                    result.ResultStatus = -1;
                    result.Message = "获取列表失败";
                }
            }
            catch (Exception e)
            {
                result.ResultStatus = -1;
                result.Message = e.Message;
            }

            return result;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 有用,创建分配公司关联表
        /// </summary>
        /// <param name="user"></param>
        /// <param name="rec"></param>
        /// <param name="details"></param>
        /// <param name="corpDetail"></param>
        /// <returns></returns>
        public ResultModel CreateCorp(UserModel user, Model.ReceivableAllot rec, List<Model.RecAllotDetail> details,Model.CorpReceivable corpDetail)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.CorpReceivableDAL corpRecDAL = new CorpReceivableDAL();
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {
                    rec.AllotType = (int)CashInAllotTypeEnum.Corp;
                    result = this.CreateMain(user, rec, ref details);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.RecAllotDetail detail in details)
                    {
                        Model.CorpReceivable corpD = new CorpReceivable();
                        corpD.AllotId = detail.AllotId;
                        corpD.BlocId = corpDetail.BlocId;
                        corpD.CorpId = corpDetail.CorpId;
                        corpD.DetailId = detail.DetailId;
                        corpD.IsShare = corpDetail.IsShare;
                        corpD.RecId = detail.RecId;

                        result = corpRecDAL.Insert(user, corpD);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }
Exemplo n.º 4
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            CorpReceivable corpreceivable = new CorpReceivable();

            int indexRefId = dr.GetOrdinal("RefId");
            corpreceivable.RefId = Convert.ToInt32(dr[indexRefId]);

            int indexAllotId = dr.GetOrdinal("AllotId");
            if (dr["AllotId"] != DBNull.Value)
            {
                corpreceivable.AllotId = Convert.ToInt32(dr[indexAllotId]);
            }

            int indexDetailId = dr.GetOrdinal("DetailId");
            if (dr["DetailId"] != DBNull.Value)
            {
                corpreceivable.DetailId = Convert.ToInt32(dr[indexDetailId]);
            }

            int indexBlocId = dr.GetOrdinal("BlocId");
            if (dr["BlocId"] != DBNull.Value)
            {
                corpreceivable.BlocId = Convert.ToInt32(dr[indexBlocId]);
            }

            int indexCorpId = dr.GetOrdinal("CorpId");
            if (dr["CorpId"] != DBNull.Value)
            {
                corpreceivable.CorpId = Convert.ToInt32(dr[indexCorpId]);
            }

            int indexRecId = dr.GetOrdinal("RecId");
            if (dr["RecId"] != DBNull.Value)
            {
                corpreceivable.RecId = Convert.ToInt32(dr[indexRecId]);
            }

            int indexIsShare = dr.GetOrdinal("IsShare");
            if (dr["IsShare"] != DBNull.Value)
            {
                corpreceivable.IsShare = Convert.ToBoolean(dr[indexIsShare]);
            }

            return corpreceivable;
        }
Exemplo n.º 5
0
        public ResultModel UpdateCorp(UserModel user, Model.ReceivableAllot rec, List<Model.RecAllotDetail> details, Model.CorpReceivable corpDetail)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.CorpReceivableDAL corpRecDAL = new CorpReceivableDAL();
                using (System.Transactions.TransactionScope scope = new TransactionScope())
                {

                    result = this.UpdateMain(user, rec, ref details);
                    if (result.ResultStatus != 0)
                        return result;

                    result = corpRecDAL.Load(user, rec.ReceivableAllotId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.CorpReceivable> corpDetails = result.ReturnValue as List<Model.CorpReceivable>;
                    if (corpDetails == null || corpDetails.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取公司明细失败";
                        return result;
                    }

                    corpDetail.BlocId = corpDetails[0].BlocId;
                    corpDetail.CorpId = corpDetails[0].CorpId;

                    foreach (Model.RecAllotDetail detail in details)
                    {
                        Model.CorpReceivable corpD = new CorpReceivable();
                        corpD.AllotId = detail.AllotId;
                        corpD.BlocId = corpDetail.BlocId;
                        corpD.CorpId = corpDetail.CorpId;
                        corpD.DetailId = detail.DetailId;
                        corpD.IsShare = corpDetail.IsShare;
                        corpD.RecId = detail.RecId;

                        result = corpRecDAL.Insert(user, corpD);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }

            return result;
        }