Exemple #1
0
        protected string GetDetailHTML(NFMT.Common.UserModel user, List<NFMT.WareHouse.Model.StockOutDetail> details)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            NFMT.WareHouse.Model.Stock stock = new NFMT.WareHouse.Model.Stock();
            NFMT.WareHouse.BLL.StockBLL stockBLL = new NFMT.WareHouse.BLL.StockBLL();
            NFMT.Common.ResultModel result = new NFMT.Common.ResultModel();

            foreach (NFMT.WareHouse.Model.StockOutDetail detail in details)
            {
                result = stockBLL.Get(user, detail.StockId);
                if (result.ResultStatus != 0)
                    continue;

                stock = result.ReturnValue as NFMT.WareHouse.Model.Stock;
                if (stock == null)
                    continue;

                sb.Append("<tr class=\"txt\">");
                sb.AppendFormat("<td>{0}</td>", stock.CardNo);
                sb.AppendFormat("<td>{0}</td>", NFMT.Data.BasicDataProvider.Assets.SingleOrDefault(a => a.AssetId == stock.AssetId).AssetName);
                sb.AppendFormat("<td>{0}</td>", NFMT.Data.BasicDataProvider.Brands.SingleOrDefault(a => a.BrandId == stock.BrandId).BrandName);
                sb.AppendFormat("<td>{0}</td>", detail.GrossAmount);
                sb.Append("<td>&nbsp;</td>");
                sb.Append("<td>&nbsp;</td>");
                sb.Append("<td>&nbsp;</td>");
                sb.Append("</tr>");

                if (string.IsNullOrEmpty(this.DPName))
                    DPName = NFMT.Data.BasicDataProvider.DeliverPlaces.SingleOrDefault(a => a.DPId == stock.DeliverPlaceId).DPName;
            }

            return sb.ToString();
        }
        public void SelectJson(NFMT.Invoice.Model.BusinessInvoice businessInvoice, NFMT.Contract.Model.ContractSub sub)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();

            if(sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.定价)
                select = bll.GetDirectFinalStocksSelect(pageIndex, pageSize, orderStr, businessInvoice.SubContractId, businessInvoice.BusinessInvoiceId, false, false);
            else
                select = bll.GetDirectStocksModel(pageIndex, pageSize, orderStr, sub.SubId, false, businessInvoice.BusinessInvoiceId);

            NFMT.Common.ResultModel result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;
            this.SubJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());

            if (sub.PriceMode == (int)NFMT.Contract.PriceModeEnum.定价)
                select = bll.GetDirectFinalStocksSelect(pageIndex, pageSize, orderStr, businessInvoice.SubContractId, businessInvoice.BusinessInvoiceId, false, true);
            else
                select = bll.GetDirectStocksModel(pageIndex, pageSize, orderStr, sub.SubId, true, businessInvoice.BusinessInvoiceId);
            result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            dt = result.ReturnValue as System.Data.DataTable;
            this.InvJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
Exemple #3
0
        /// <summary>
        /// 同步工作流冻结
        /// 业务数据冻结同时调用
        /// </summary>
        /// <param name="tableName"></param>
        /// <param name="rowId"></param>
        /// <returns></returns>
        public NFMT.Common.ResultModel SynDataFreeze(NFMT.Common.UserModel user, string tableName, int rowId)
        {
            Common.ResultModel result = new Common.ResultModel();

            try
            {
                result = this.GetSourceId(tableName, rowId);
                if (result.ResultStatus != 0)
                    return result;

                int SourceId = Convert.ToInt32(result.ReturnValue);
                NFMT.WorkFlow.BLL.DataSourceBLL dataSourceBll = new BLL.DataSourceBLL();
                result = dataSourceBll.Get(user, SourceId);
                if (result.ResultStatus != 0)
                    return result;

                NFMT.WorkFlow.Model.DataSource dataSource = result.ReturnValue as NFMT.WorkFlow.Model.DataSource;

                result = dataSourceBll.Freeze(user, dataSource);
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            return result;
        }
        public void SelectJson(int provisionalInvoiceId, NFMT.Contract.Model.ContractSub sub)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();

            select = bll.GetReplaceFinalStocksSelect(pageIndex, pageSize, orderStr, provisionalInvoiceId);
            NFMT.Common.ResultModel result = bll.Load(user, select, NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            decimal sumBala = dt.Select().Sum(temp => Convert.ToDecimal(temp["Bala"]));
            decimal sumNetAmount = dt.Select().Sum(temp => Convert.ToDecimal(temp["NetAmount"]));

            if (sumNetAmount == 0)
                this.WarmAlert("未确认价格,禁止开终票", "InvoiceReplaceFinalList.aspx");

            this.netAmount = sumNetAmount;
            this.invoiceBala = Math.Round(sumBala, 2, MidpointRounding.AwayFromZero);
            this.AvgPrice = Math.Round(this.invoiceBala / sumNetAmount, 4, MidpointRounding.AwayFromZero);

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
Exemple #5
0
 /// <summary>
 /// 发票收取,返回发票序号
 /// </summary>
 /// <param name="user">用户</param>
 /// <param name="invoice">发票</param>
 /// <param name="invoiceAttach">发票附件</param>
 /// <returns></returns>
 public int InvoiceReceive(NFMT.Common.UserModel user, NFMT.Invoice.Model.Invoice invoice, List<NFMT.Invoice.Model.InvoiceAttach> invoiceAttachs)
 {
     NFMT.Common.ResultModel result = invoiceBLL.InvoiceHandle(user, invoice, invoiceAttachs, NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.发票方向)["收取"]);
     if (result.ResultStatus != 0)
         return -1;
     else
         return (int)result.ReturnValue;
 }
Exemple #6
0
        /// <summary>
        /// 入库
        /// </summary>
        /// <param name="stockLog">入库流水</param>
        /// <param name="user">当前用户</param>
        /// <param name="stockLogAttachs"></param>
        /// <returns></returns>
        public bool StockIn(NFMT.Common.UserModel user, NFMT.WareHouse.Model.StockLog stockLog, List<NFMT.WareHouse.Model.StockLogAttach> stockLogAttachs)
        {
            NFMT.Common.ResultModel result =
             logBLL.StockHandle(user, stockLog, stockLogAttachs, NFMT.Data.DetailProvider.Details(NFMT.Data.StyleEnum.流水类型)["入库"]);

            if (result.ResultStatus == 0)
                return true;
            return false;
        }
        public void SelectJson(NFMT.Invoice.Model.BusinessInvoice businessInvoice, NFMT.Invoice.InvoiceDirectionEnum direction)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();

            select = bll.GetDirectFinalContractStockListSelect(pageIndex, pageSize, orderStr, businessInvoice.SubContractId, businessInvoice.BusinessInvoiceId,true,true);
            NFMT.Common.ResultModel result = bll.Load(user, select,NFMT.Common.DefaultValue.ClearAuth);
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
        public void SelectJson(NFMT.Funds.Model.Payment payment)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;

            NFMT.Funds.BLL.PaymentBLL bll = new NFMT.Funds.BLL.PaymentBLL();
            NFMT.Common.SelectModel select = bll.GetInvoiceCreateSelect(pageIndex, pageSize, orderStr, payment.PayApplyId, payment.PaymentId);
            NFMT.Common.ResultModel result = bll.Load(user, select,new NFMT.Common.BasicAuth());

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
Exemple #9
0
        public void SelectJson(int subId, NFMT.Invoice.InvoiceDirectionEnum direction)
        {
            int pageIndex = 1, pageSize = 100;
            string orderStr = string.Empty, whereStr = string.Empty;

            NFMT.Common.UserModel user = Utility.UserUtility.CurrentUser;
            NFMT.Common.SelectModel select = new NFMT.Common.SelectModel();
            NFMT.Invoice.BLL.BusinessInvoiceBLL bll = new NFMT.Invoice.BLL.BusinessInvoiceBLL();
            select = bll.GetProvisionalContractStockListSelect(pageIndex, pageSize, orderStr, subId);
            NFMT.Common.ResultModel result = bll.Load(user, select);

            int totalRows = result.AffectCount;
            System.Data.DataTable dt = result.ReturnValue as System.Data.DataTable;

            this.SelectedJson = Newtonsoft.Json.JsonConvert.SerializeObject(dt, new Newtonsoft.Json.Converters.DataTableConverter());
        }
Exemple #10
0
        public ResultModel GetStockInfoByAlotId(UserModel user, int allotId, NFMT.Common.StatusEnum status)
        {
            ResultModel result = new ResultModel();

            try
            {
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("select slog.StockLogId,slog.StockId,slog.StockNameId,slog.RefNo,corp.CorpName,ass.AssetName,brand.BrandName,bd.StatusName,mu.MUName,slog.NetAmount+ISNULL(slog.GapAmount,0) NetGapAmount,ref.AllotBala,dp.DPName,slog.CardNo,ref.AllotNetAmount ");
                sb.Append(" from NFMT..Fun_CashInStcok_Ref ref ");
                sb.Append(" left join NFMT..St_StockLog slog on ref.StockLogId = slog.StockLogId ");
                sb.Append(" left join NFMT..St_Stock st on slog.StockId = st.StockId ");
                sb.Append(" left join NFMT_User..Corporation corp on st.CorpId = corp.CorpId ");
                sb.Append(" left join NFMT_Basic..Asset ass on slog.AssetId = ass.AssetId ");
                sb.Append(" left join NFMT_Basic..Brand brand on slog.BrandId = brand.BrandId ");
                sb.Append(" left join NFMT_Basic.dbo.DeliverPlace dp on dp.DPId = st.DeliverPlaceId ");
                sb.AppendFormat(" left join NFMT_Basic..BDStatusDetail bd on bd.DetailId = st.StockStatus and bd.StatusId = {0} ", (int)NFMT.Common.StatusTypeEnum.库存状态);
                sb.Append(" left join NFMT_Basic..MeasureUnit mu on slog.MUId = mu.MUId ");
                sb.AppendFormat(" where ref.AllotId = {0} and ref.DetailStatus = {1} ", allotId, (int)status);

                DataTable dt = NFMT.DBUtility.SqlHelper.ExecuteDataTable(this.ConnectString, sb.ToString(), null, CommandType.Text);
                if (dt != null && dt.Rows.Count > 0)
                {
                    result.ResultStatus = 0;
                    result.ReturnValue = dt;
                    result.Message = "获取成功";
                }
                else
                {
                    result.ResultStatus = -1;
                    result.Message = "获取失败";
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
        private void InitCashInInfo(NFMT.Funds.Model.CashIn cashIn,string redirectUrl)
        {
            NFMT.User.Model.Corporation inCorp = NFMT.User.UserProvider.Corporations.SingleOrDefault(a => a.CorpId == cashIn.CashInCorpId);
            if (inCorp == null)
                Utility.JsUtility.WarmAlert(this.Page, "获取收款公司失败", redirectUrl);
            InCorpName = inCorp.CorpName;

            NFMT.Data.Model.Bank inBank = NFMT.Data.BasicDataProvider.Banks.SingleOrDefault(a => a.BankId == cashIn.CashInBank);
            if (inBank == null)
                Utility.JsUtility.WarmAlert(this.Page, "获取收款银行失败", redirectUrl);
            InBankName = inBank.BankName;

            NFMT.Data.Model.BankAccount inBankAccount = NFMT.Data.BasicDataProvider.BankAccounts.SingleOrDefault(a => a.BankAccId == cashIn.CashInAccoontId);
            if (inBankAccount == null)
                Utility.JsUtility.WarmAlert(this.Page, "获取收款银行账号失败", redirectUrl);
            InBankAccountNo = inBankAccount.AccountNo;

            NFMT.Data.Model.Currency currency = NFMT.Data.BasicDataProvider.Currencies.SingleOrDefault(a => a.CurrencyId == cashIn.CurrencyId);
            if (currency == null)
                Utility.JsUtility.WarmAlert(this.Page, "获取币种失败", redirectUrl);
            CurrencyName = currency.CurrencyName;
        }
Exemple #12
0
        public ResultModel ValidateAuth(NFMT.Common.UserModel user, Model.StockIn stockIn)
        {
            NFMT.Common.ResultModel result = new ResultModel();

            //验证权限
            //1:验证是否有己方公司权限
            //3:以上条件下是否具有内外贸权限
            //5:以上条件下是否具有品种权限

            NFMT.User.DAL.AuthGroupDAL dal = new User.DAL.AuthGroupDAL();

            result = dal.LoadByEmpId(user.EmpId);
            if (result.ResultStatus != 0)
                return result;

            List<NFMT.User.Model.AuthGroup> authGroups = result.ReturnValue as List<NFMT.User.Model.AuthGroup>;

            if (authGroups == null)
            {
                result.ResultStatus = -1;
                result.Message = "权限验证失败";
                return result;
            }

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("当前用户不拥有");

            IEnumerable<NFMT.User.Model.AuthGroup> temps = new List<User.Model.AuthGroup>();

            //验证是否有己方公司权限
            temps = authGroups.FindAll(temp => (temp.CorpId == stockIn.CorpId || temp.CorpId == 0));

            NFMT.User.Model.Corporation corp = NFMT.User.UserProvider.Corporations.FirstOrDefault(temp => temp.CorpId == stockIn.CorpId);
            if (corp == null || corp.CorpId <= 0)
            {
                result.ResultStatus = -1;
                result.Message = "己方公司不存在";
                return result;
            }

            if (temps == null || temps.Count() == 0)
            {
                result.ResultStatus = -1;
                result.Message = string.Format("当前用户不拥有[{0}]权限", corp.CorpName);
                return result;
            }

            sb.AppendFormat("[{0}]", corp.CorpName);

            NFMT.WareHouse.CustomTypeEnum customsType = (NFMT.WareHouse.CustomTypeEnum)stockIn.CustomType;
            sb.AppendFormat(" {0} ", customsType.ToString("F"));
            NFMT.Data.Model.Asset asset = NFMT.Data.BasicDataProvider.Assets.FirstOrDefault(temp => temp.AssetId == stockIn.AssetId);
            if (asset == null || asset.AssetId <= 0)
            {
                result.ResultStatus = -1;
                result.Message = "所选品种不存在";
                return result;
            }
            sb.AppendFormat(" {0} ", asset.AssetName);
            sb.Append("权限");

            //1:以上条件下是否具有内外贸权限
            //temps = temps.Where(temp => temp.TradeBorder == stockIn.CustomType || temp.TradeBorder == 0);

            authGroups = new List<User.Model.AuthGroup>();
            foreach (NFMT.User.Model.AuthGroup auth in temps)
            {
                NFMT.Contract.TradeBorderEnum tradeBorder = (NFMT.Contract.TradeBorderEnum)auth.TradeBorder;
                if (auth.TradeBorder == 0)
                    authGroups.Add(auth);
                else if (customsType == CustomTypeEnum.关外 && tradeBorder == Contract.TradeBorderEnum.外贸)
                    authGroups.Add(auth);
                else if (customsType == CustomTypeEnum.关内 && tradeBorder == Contract.TradeBorderEnum.内贸)
                    authGroups.Add(auth);
            }
            temps = authGroups;
            if (temps == null || temps.Count() == 0)
            {
                result.ResultStatus = -1;
                result.Message = sb.ToString();
                return result;
            }

            //2:以上条件下是否具有品种权限
            temps = authGroups.Where(temp => temp.AssetId == stockIn.AssetId || temp.AssetId == 0);
            if (temps == null || temps.Count() == 0)
            {
                result.ResultStatus = -1;
                result.Message = sb.ToString();
                return result;
            }

            if (temps.Count() > 0)
            {
                result.ResultStatus = 0;
                result.Message = "满足权限";
            }

            return result;
        }
Exemple #13
0
        public ResultModel RepoApplyUpdateHandle(UserModel user, NFMT.Operate.Model.Apply apply, int repoApplyId, List<Model.RepoApplyDetail> details)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply applyRes = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (applyRes == null)
                    {
                        result.ResultStatus = -1;
                        result.Message = "获取申请失败";
                        return result;
                    }

                    applyRes.ApplyTime = apply.ApplyTime;
                    applyRes.EmpId = apply.EmpId;
                    applyRes.ApplyDept = apply.ApplyDept;
                    applyRes.ApplyCorp = apply.ApplyCorp;
                    applyRes.ApplyDesc = apply.ApplyDesc;

                    result = applyDAL.Update(user, applyRes);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.DAL.RepoApplyDetailDAL repoApplyDetailDAL = new RepoApplyDetailDAL();
                    result = repoApplyDetailDAL.InvalidAll(user, repoApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    foreach (Model.RepoApplyDetail detail in details)
                    {
                        result = repoApplyDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
        public ResultModel UpdateDetailStatus(UserModel user, int pledgeApplyId,NFMT.Common.StatusEnum status)
        {
            ResultModel result = new ResultModel();

            try
            {
                string sql = string.Format("update dbo.Fin_PledgeApplyStockDetail set DetailStatus = {0} where PledgeApplyId = {1}", (int)status, pledgeApplyId);
                int i = NFMT.DBUtility.SqlHelper.ExecuteNonQuery(this.ConnectString, CommandType.Text, sql, null);
                if (i > 0)
                {
                    result.Message = "更新成功";
                    result.ResultStatus = 0;
                }
                else
                {
                    result.Message = "更新失败";
                    result.ResultStatus = -1;
                }
            }
            catch (Exception e)
            {
                result.Message = e.Message;
                result.ResultStatus = -1;
            }

            return result;
        }
Exemple #15
0
        public ResultModel Update(UserModel user, NFMT.DoPrice.Model.Interest interest, List<NFMT.DoPrice.Model.InterestDetail> details)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.InterestDetailDAL detailDAL = new InterestDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (details == null || details.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "请添加利息信息";
                        return result;
                    }

                    //获取结算
                    result = this.interestDAL.Get(user, interest.InterestId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.Interest resultInterest = result.ReturnValue as Model.Interest;
                    if (resultInterest == null || resultInterest.InterestId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "结息不存在";
                        return result;
                    }

                    //本金计息方式下,计算当前结息成本
                    if (resultInterest.InterestStyle == (int)NFMT.DoPrice.InterestStyleEnum.本金计息)
                    {
                        decimal curCapital = details.Where(temp => temp.InterestType != (int)NFMT.DoPrice.InterestTypeEnum.差额计息).Sum(temp => temp.StockBala);
                        interest.CurCapital = Math.Round(curCapital, 2, MidpointRounding.AwayFromZero);

                        decimal sumCapital = details.Sum(temp => temp.StockBala);
                        if (sumCapital != interest.PayCapital)
                        {
                            result.Message = "结算总金额必须等于预付本金";
                            result.ResultStatus = -1;
                            return result;
                        }
                    }

                    decimal sumInterestBala = details.Sum(temp => temp.InterestBala);
                    if (sumInterestBala != interest.InterestBala)
                    {
                        result.Message = "利息明细之和必须等于利息总额";
                        result.ResultStatus = -1;
                        return result;
                    }

                    //赋值主表
                    resultInterest.CurCapital = interest.CurCapital;
                    resultInterest.InterestAmount = interest.InterestAmount;
                    resultInterest.InterestAmountDay = interest.InterestAmountDay;
                    resultInterest.InterestBala = interest.InterestBala;
                    resultInterest.InterestDate = interest.InterestDate;
                    resultInterest.InterestPrice = interest.InterestPrice;
                    resultInterest.InterestRate = interest.InterestRate;
                    resultInterest.Memo = interest.Memo;
                    resultInterest.OtherPrice = interest.OtherPrice;
                    resultInterest.PayCapital = interest.PayCapital;
                    resultInterest.Premium = interest.Premium;
                    resultInterest.PricingUnit = interest.PricingUnit;

                    result = this.interestDAL.Update(user, resultInterest);
                    if (result.ResultStatus != 0)
                        return result;

                    //作废原有明细
                    result = detailDAL.Load(user, resultInterest.InterestId);
                    if (result.ResultStatus != 0)
                        return result;

                    List<Model.InterestDetail> resultDetails = result.ReturnValue as List<Model.InterestDetail>;
                    if (resultDetails == null || resultDetails.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "结息明细获取失败";
                        return result;
                    }

                    foreach (Model.InterestDetail detail in resultDetails)
                    {
                        detail.DetailStatus = StatusEnum.已录入;
                        result = detailDAL.Invalid(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    //添加新明细
                    foreach (NFMT.DoPrice.Model.InterestDetail detail in details)
                    {
                        detail.InterestId = resultInterest.InterestId;
                        detail.DetailStatus = StatusEnum.已生效;
                        detail.SubContractId = interest.SubContractId;
                        detail.ContractId = interest.ContractId;
                        detail.InterestPrice = interest.InterestPrice;
                        detail.PricingUnit = interest.PricingUnit;
                        detail.Premium = interest.Premium;
                        detail.OtherPrice = interest.OtherPrice;

                        if (detail.InterestType != (int)InterestTypeEnum.差额计息)
                        {
                            if (resultInterest.InterestStyle == (int)InterestStyleEnum.本金计息)
                                detail.InterestType = (int)InterestTypeEnum.本金计息;
                            else
                                detail.InterestType = (int)InterestTypeEnum.货值计息;

                        }
                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Exemple #16
0
        public ResultModel Create(UserModel user, NFMT.DoPrice.Model.Interest interest, List<NFMT.DoPrice.Model.InterestDetail> details, bool isSubmitAudit)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.InterestDetailDAL detailDAL = new InterestDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    if (details == null || details.Count == 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "请添加利息信息";
                        return result;
                    }

                    //本金计息方式下,计算当前结息成本
                    if (interest.InterestStyle == (int)NFMT.DoPrice.InterestStyleEnum.本金计息)
                    {
                        decimal curCapital = details.Where(temp=> temp.InterestType != (int)NFMT.DoPrice.InterestTypeEnum.差额计息).Sum(temp => temp.StockBala);
                        interest.CurCapital = Math.Round(curCapital,2,MidpointRounding.AwayFromZero);

                        decimal sumCapital =details.Sum(temp=>temp.StockBala);
                        if(sumCapital != interest.PayCapital)
                        {
                            result.Message="结算总金额必须等于预付本金";
                            result.ResultStatus=-1;
                            return result;
                        }
                    }

                    decimal sumInterestBala = details.Sum(temp => temp.InterestBala);
                    if (sumInterestBala != interest.InterestBala)
                    {
                        result.Message = "利息明细之和必须等于利息总额";
                        result.ResultStatus = -1;
                        return result;
                    }

                    interest.InterestStatus = StatusEnum.已录入;
                    result = this.interestDAL.Insert(user, interest);
                    if (result.ResultStatus != 0)
                        return result;

                    int interestId = 0;
                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out interestId) || interestId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "利息新增失败";
                        return result;
                    }

                    foreach (NFMT.DoPrice.Model.InterestDetail detail in details)
                    {
                        detail.InterestId = interestId;
                        detail.DetailStatus = StatusEnum.已生效;
                        detail.SubContractId = interest.SubContractId;
                        detail.ContractId = interest.ContractId;
                        detail.InterestPrice = interest.InterestPrice;
                        detail.PricingUnit = interest.PricingUnit;
                        detail.Premium = interest.Premium;
                        detail.OtherPrice = interest.OtherPrice;

                        if (detail.InterestType != (int)InterestTypeEnum.差额计息)
                        {
                            if (interest.InterestStyle == (int)InterestStyleEnum.本金计息)
                                detail.InterestType = (int)InterestTypeEnum.本金计息;
                            else
                                detail.InterestType = (int)InterestTypeEnum.货值计息;

                        } result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    if (isSubmitAudit)
                    {
                        interest.InterestId = interestId;

                        NFMT.WorkFlow.AutoSubmit submit = new WorkFlow.AutoSubmit();
                        NFMT.WorkFlow.ITaskProvider taskProvider = new NFMT.DoPrice.TaskProvider.InterestTaskProvider();
                        result = submit.Submit(user, interest, taskProvider, WorkFlow.MasterEnum.利息结算审核);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Exemple #17
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;
        }
Exemple #18
0
        /// <summary>
        /// 有用,获取当前分配的公司明细
        /// </summary>
        /// <param name="user"></param>
        /// <param name="allotId"></param>
        /// <returns></returns>
        public ResultModel GetRowsDetail(UserModel user, int allotId,NFMT.Common.StatusEnum status = StatusEnum.已生效)
        {
            ResultModel result = new ResultModel();

            try
            {
                result = corpreceivableDAL.GetRowsDetail(user, allotId,status);
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    this.Log.ErrorFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (this.Log.IsInfoEnabled)
                    this.Log.InfoFormat("{0} {1},序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Exemple #19
0
        public ResultModel Load(UserModel user, int documentId, NFMT.Common.StatusEnum status = StatusEnum.已生效)
        {
            string cmdText = string.Format("select * from NFMT.dbo.Doc_DocumentInvoice where DocumentId ={0} and DetailStatus = {1} ", documentId, (int)status);

            ResultModel result = this.Load<Model.DocumentInvoice>(user, CommandType.Text, cmdText);

            return result;
        }
Exemple #20
0
        public ResultModel CreateStockReceipt(UserModel user, NFMT.WareHouse.Model.StockReceipt stockReceipt, List<NFMT.WareHouse.Model.StockReceiptDetail> details, List<NFMT.WareHouse.Model.StockReceiptDetail> saleDetails, bool isAudit)
        {
            ResultModel result = new ResultModel();

            try
            {
                NFMT.Contract.DAL.ContractSubDAL subDAL = new Contract.DAL.ContractSubDAL();
                NFMT.Contract.DAL.ContractDAL contractDAL = new Contract.DAL.ContractDAL();
                NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL();
                NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                DAL.StockReceiptDAL receiptDAL = new StockReceiptDAL();
                DAL.StockReceiptDetailDAL detailDAL = new StockReceiptDetailDAL();

                using (System.Transactions.TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    //验证合约
                    result = subDAL.Get(user, stockReceipt.ContractSubId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.ContractSub sub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                    if (sub.SubId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "子合约不存在";
                        return result;
                    }

                    result = contractDAL.Get(user, sub.ContractId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Contract.Model.Contract contract = result.ReturnValue as NFMT.Contract.Model.Contract;
                    if (contract == null || contract.ContractId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "合约不存在";
                        return result;
                    }

                    decimal sumNetAmount = 0;
                    decimal sumReceiptAmount = 0;
                    decimal sumMissAmount = 0;
                    decimal missRate = 0;

                    //明细验证
                    foreach (NFMT.WareHouse.Model.StockReceiptDetail detail in details)
                    {
                        if (detail.ReceiptAmount > 0)
                        {
                            //验证库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.Stock stock = result.ReturnValue as Model.Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存不存在";
                                return result;
                            }

                            //验证流水
                            result = stockLogDAL.Get(user, detail.StockLogId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                            if (stockLog == null || stockLog.StockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存流水不存在";
                                return result;
                            }

                            if (stockLog.StockId != stock.StockId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存与库存流水不匹配";
                                return result;
                            }

                            if (stockLog.SubContractId != stockReceipt.ContractSubId)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存流水与合约不匹配";
                                return result;
                            }

                            detail.ContractId = sub.ContractId;
                            detail.ContractSubId = sub.SubId;
                            detail.DetailStatus = StatusEnum.已生效;
                            detail.PreNetAmount = stock.NetAmount;
                            detail.QtyMiss = detail.ReceiptAmount - stock.NetAmount;
                            detail.QtyRate = (detail.ReceiptAmount / stock.NetAmount - 1) / 100;

                            sumNetAmount += stock.NetAmount;
                            sumReceiptAmount += detail.ReceiptAmount;
                        }
                    }

                    sumMissAmount = sumReceiptAmount - sumNetAmount;
                    missRate = (sumReceiptAmount / sumNetAmount - 1) / 100;

                    //赋值StockReceipt
                    stockReceipt.ContractId = sub.ContractId;
                    stockReceipt.ContractSubId = sub.SubId;
                    stockReceipt.PreNetAmount = sumNetAmount;
                    stockReceipt.QtyMiss = sumMissAmount;
                    stockReceipt.QtyRate = missRate;
                    stockReceipt.ReceiptAmount = sumReceiptAmount;
                    stockReceipt.Receipter = user.EmpId;
                    stockReceipt.ReceiptDate = DateTime.Now;

                    if (contract.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                        stockReceipt.ReceiptType = (int)WareHouse.ReceiptTypeEnum.StockInReceipt;
                    else
                        stockReceipt.ReceiptType = (int)WareHouse.ReceiptTypeEnum.StockOutReceipt;

                    stockReceipt.UnitId = sub.UnitId;

                    //新增StockReceipt
                    result = stockreceiptDAL.Insert(user, stockReceipt);
                    if (result.ResultStatus != 0)
                        return result;

                    int receiptId = 0;
                    if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out receiptId))
                    {
                        result.ResultStatus = -1;
                        result.Message = "新增库存回执失败";
                        return result;
                    }

                    //新增明细
                    foreach (NFMT.WareHouse.Model.StockReceiptDetail detail in details)
                    {
                        detail.ReceiptId = receiptId;
                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    stockReceipt.ReceiptId = receiptId;
                    string resultStr = Newtonsoft.Json.JsonConvert.SerializeObject(stockReceipt);

                    //if(isAudit)
                    //{
                    //    stockReceipt.ReceiptId = receiptId;
                    //    NFMT.WorkFlow.AutoSubmit submit = new NFMT.WorkFlow.AutoSubmit();
                    //    result = submit.Submit(user, stockReceipt, new TaskProvider.StockReceiptTaskProvider(), NFMT.WorkFlow.MasterEnum.库存净重回执审核);
                    //    if (result.ResultStatus != 0)
                    //        return result;
                    //}

                    #region 销售合约库存回执

                    if (saleDetails != null && saleDetails.Any())
                    {
                        foreach (int subId in saleDetails.Select(a => a.ContractSubId).Distinct())
                        {
                            //验证合约
                            result = subDAL.Get(user, subId);
                            if (result.ResultStatus != 0)
                                return result;

                            NFMT.Contract.Model.ContractSub saleSub = result.ReturnValue as NFMT.Contract.Model.ContractSub;
                            if (saleSub.SubId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "子合约不存在";
                                return result;
                            }

                            sumNetAmount = 0;
                            sumReceiptAmount = 0;
                            sumMissAmount = 0;
                            missRate = 0;

                            //明细验证
                            foreach (NFMT.WareHouse.Model.StockReceiptDetail detail in saleDetails.Where(a => a.ContractSubId == subId))
                            {
                                if (detail.ReceiptAmount > 0)
                                {
                                    //验证库存
                                    result = stockDAL.Get(user, detail.StockId);
                                    if (result.ResultStatus != 0)
                                        return result;

                                    Model.Stock stock = result.ReturnValue as Model.Stock;
                                    if (stock == null || stock.StockId <= 0)
                                    {
                                        result.ResultStatus = -1;
                                        result.Message = "库存不存在";
                                        return result;
                                    }

                                    //验证流水
                                    result = stockLogDAL.Get(user, detail.StockLogId);
                                    if (result.ResultStatus != 0)
                                        return result;

                                    Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                                    if (stockLog == null || stockLog.StockLogId <= 0)
                                    {
                                        result.ResultStatus = -1;
                                        result.Message = "库存流水不存在";
                                        return result;
                                    }

                                    if (stockLog.StockId != stock.StockId)
                                    {
                                        result.ResultStatus = -1;
                                        result.Message = "库存与库存流水不匹配";
                                        return result;
                                    }

                                    if (stockLog.SubContractId != subId)
                                    {
                                        result.ResultStatus = -1;
                                        result.Message = "库存流水与合约不匹配";
                                        return result;
                                    }

                                    detail.ContractId = saleSub.ContractId;
                                    detail.ContractSubId = saleSub.SubId;
                                    detail.DetailStatus = StatusEnum.已生效;
                                    detail.PreNetAmount = stock.NetAmount;
                                    detail.QtyMiss = detail.ReceiptAmount - stock.NetAmount;
                                    detail.QtyRate = (detail.ReceiptAmount / stock.NetAmount - 1) / 100;

                                    sumNetAmount += stock.NetAmount;
                                    sumReceiptAmount += detail.ReceiptAmount;
                                }
                            }

                            sumMissAmount = sumReceiptAmount - sumNetAmount;
                            missRate = (sumReceiptAmount / sumNetAmount - 1) / 100;

                            //赋值StockReceipt
                            stockReceipt.ContractId = saleSub.ContractId;
                            stockReceipt.ContractSubId = saleSub.SubId;
                            stockReceipt.PreNetAmount = sumNetAmount;
                            stockReceipt.ReceiptAmount = sumReceiptAmount;
                            stockReceipt.UnitId = saleSub.UnitId;
                            stockReceipt.QtyMiss = sumMissAmount;
                            stockReceipt.QtyRate = missRate;
                            stockReceipt.Receipter = user.EmpId;
                            stockReceipt.ReceiptDate = DateTime.Now;

                            if (saleSub.TradeDirection == (int)NFMT.Contract.TradeDirectionEnum.Buy)
                                stockReceipt.ReceiptType = (int)WareHouse.ReceiptTypeEnum.StockInReceipt;
                            else
                                stockReceipt.ReceiptType = (int)WareHouse.ReceiptTypeEnum.StockOutReceipt;

                            //新增StockReceipt
                            result = stockreceiptDAL.Insert(user, stockReceipt);
                            if (result.ResultStatus != 0)
                                return result;

                            receiptId = 0;
                            if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out receiptId))
                            {
                                result.ResultStatus = -1;
                                result.Message = "新增库存回执失败";
                                return result;
                            }

                            //新增明细
                            foreach (NFMT.WareHouse.Model.StockReceiptDetail detail in saleDetails.Where(a => a.ContractSubId == subId))
                            {
                                detail.ReceiptId = receiptId;
                                result = detailDAL.Insert(user, detail);
                                if (result.ResultStatus != 0)
                                    return result;
                            }
                        }

                        //if (isAudit)
                        //{
                        //    stockReceipt.ReceiptId = receiptId;
                        //    NFMT.WorkFlow.AutoSubmit submit = new NFMT.WorkFlow.AutoSubmit();
                        //    result = submit.Submit(user, stockReceipt, new TaskProvider.StockReceiptTaskProvider(), NFMT.WorkFlow.MasterEnum.库存净重回执审核);
                        //    if (result.ResultStatus != 0)
                        //        return result;
                        //}
                    }

                    #endregion

                    stockReceipt.ReceiptId = receiptId;
                    if (result.ResultStatus == 0)
                    {
                        if (saleDetails != null && saleDetails.Any())
                            result.ReturnValue = stockReceipt;
                        else
                            result.ReturnValue = null;

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

            return result;
        }
Exemple #21
0
 public CorpDetailAttach(NFMT.Operate.AttachType _attachType)
 {
     this.attachType = (int)_attachType;
 }
Exemple #22
0
        //报关审核生效	   流水操作:写入 流水类型:报关 流水状态:已生效    库存操作:更新 库存状态:预报关库存
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.customsclearanceDAL.Get(user, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.CustomsClearance customsClearance = result.ReturnValue as Model.CustomsClearance;
                    if (customsClearance == null || customsClearance.CustomsId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "报关不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.customsclearanceDAL.Audit(user, customsClearance, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //加载已生效明细
                        DAL.CustomsDetailDAL customsDetailDAL = new CustomsDetailDAL();
                        result = customsDetailDAL.Load(user, customsClearance.CustomsId, StatusEnum.已生效);
                        if (result.ResultStatus != 0)
                            return result;

                        List<Model.CustomsDetail> details = result.ReturnValue as List<Model.CustomsDetail>;
                        if (details == null || !details.Any())
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取失败";
                            return result;
                        }

                        DAL.StockDAL stockDAL = new StockDAL();
                        DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                        DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                        Model.Stock stock = null;
                        Model.StockName stockName = null;
                        Model.StockLog stockLog = null;

                        foreach (Model.CustomsDetail detail in details)
                        {
                            //获取库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            stock = result.ReturnValue as Model.Stock;
                            if (stock == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取库存失败";
                                return result;
                            }

                            //获取业务单号
                            result = stockNameDAL.Get(user, stock.StockNameId);
                            if (result.ResultStatus != 0)
                                return result;

                            stockName = result.ReturnValue as Model.StockName;
                            if (stockName == null)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取业务单号失败";
                                return result;
                            }

                            //创建库存流水
                            stockLog = new StockLog()
                            {
                                StockId = stock.StockId,
                                StockNameId = stock.StockNameId,
                                RefNo = stockName.RefNo,
                                LogDirection = (int)LogDirectionEnum.Out,
                                LogType = (int)LogTypeEnum.报关,
                                //ContractId =
                                //SubContractId =
                                LogDate = DateTime.Now,
                                OpPerson = user.EmpId,
                                Bundles = stock.Bundles,
                                GrossAmount = stock.GrossAmount,
                                NetAmount = stock.NetAmount,
                                MUId = stock.UintId,
                                BrandId = stock.BrandId,
                                DeliverPlaceId = stock.DeliverPlaceId,
                                PaperNo = stock.PaperNo,
                                PaperHolder = stock.PaperHolder,
                                CardNo = stock.CardNo,
                                Memo = stock.Memo,
                                LogStatus = StatusEnum.已生效,
                                LogSourceBase = "NFMT",
                                LogSource = "dbo.St_CustomsClearance",
                                SourceId = customsClearance.CustomsId
                            };

                            result = stockLogDAL.Insert(user, stockLog);
                            if (result.ResultStatus != 0)
                                return result;

                            int stockLogId = 0;
                            if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "流水添加失败";
                                return result;
                            }

                            //将库存流水Id反向更新到明细表中
                            detail.StockLogId = stockLogId;
                            result = customsDetailDAL.Update(user, detail);
                            if (result.ResultStatus != 0)
                                return result;

                            //更新库存状态
                            result = stockDAL.UpdateStockStatus(stock, StockStatusEnum.预报关库存);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

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

            return result;
        }
Exemple #23
0
 public override NFMT.Common.ResultModel Insert(NFMT.Common.UserModel user, NFMT.Common.IModel obj)
 {
     obj.Status = StatusEnum.已生效;
     return base.Insert(user, obj);
 }
Exemple #24
0
 public ResultModel Load(UserModel user, int allotId, NFMT.Common.StatusEnum status = StatusEnum.已生效)
 {
     return this.corpreceivableDAL.Load(user, allotId, status);
 }
Exemple #25
0
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                NFMT.WareHouse.DAL.StockNameDAL stockNameDAL = new StockNameDAL();
                DAL.ContractStockInDAL contractStockInDAL = new ContractStockInDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.stockinDAL.Get(user, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockIn stockIn = result.ReturnValue as Model.StockIn;
                    if (stockIn == null || stockIn.StockInId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "入库登记不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.stockinDAL.Audit(user, stockIn, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //写入St_StockName表
                        result = stockNameDAL.Insert(user, new Model.StockName() { RefNo = stockIn.RefNo });
                        if (result.ResultStatus != 0)
                            return result;

                        int stockNameId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockNameId) || stockNameId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "写库存失败";
                            return result;
                        }

                        //写入St_Stock库存表
                        result = stockDAL.Insert(user, new Model.Stock()
                        {
                            StockNameId = stockNameId,
                            StockDate = stockIn.StockInDate,
                            AssetId = stockIn.AssetId,
                            Bundles = stockIn.Bundles,
                            GrossAmount = stockIn.GrossAmount,
                            NetAmount = stockIn.NetAmount,
                            ReceiptInGap = 0,
                            ReceiptOutGap = 0,
                            CurGrossAmount = stockIn.GrossAmount,
                            CurNetAmount = stockIn.NetAmount,
                            UintId = stockIn.UintId,
                            DeliverPlaceId = stockIn.DeliverPlaceId,
                            BrandId = stockIn.BrandId,
                            CustomsType = stockIn.CustomType,
                            GroupId = stockIn.GroupId,
                            CorpId = stockIn.CorpId,
                            DeptId = stockIn.DeptId,
                            ProducerId = stockIn.ProducerId,
                            PaperNo = stockIn.PaperNo,
                            PaperHolder = stockIn.PaperHolder,
                            PreStatus = StockStatusEnum.预入库存,
                            StockStatus = StockStatusEnum.预入库存,
                            CardNo = stockIn.CardNo,
                            Memo = string.Empty,
                            StockType = stockIn.StockType,
                            OriginPlaceId = stockIn.OriginPlaceId,
                            OriginPlace = stockIn.OriginPlace,
                            Format = stockIn.Format
                        });
                        if (result.ResultStatus != 0)
                            return result;

                        int stockId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockId) || stockId <= 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "写库存失败";
                            return result;
                        }

                        int contractId = 0, subId = 0;

                        //获取合约关联
                        result = contractStockInDAL.GetByStockInId(user, stockIn.StockInId);
                        if (result.ResultStatus == 0)
                        {
                            Model.ContractStockIn contractStockIn = result.ReturnValue as Model.ContractStockIn;
                            if (contractStockIn != null && contractStockIn.RefId > 0)
                            {
                                contractId = contractStockIn.ContractId;
                                subId = contractStockIn.ContractSubId;
                            }
                        }

                        //创建stockLog对象
                        NFMT.WareHouse.Model.StockLog stockLog = new StockLog()
                        {
                            StockId = stockId,
                            StockNameId = stockNameId,
                            RefNo = stockIn.RefNo,
                            LogDirection = (int)LogDirectionEnum.In,
                            LogType = (int)LogTypeEnum.入库,
                            ContractId = contractId,
                            SubContractId = subId,
                            LogDate = DateTime.Now,
                            OpPerson = user.EmpId,
                            Bundles = stockIn.Bundles,
                            GrossAmount = stockIn.GrossAmount,
                            NetAmount = stockIn.NetAmount,
                            MUId = stockIn.UintId,
                            BrandId = stockIn.BrandId,
                            DeliverPlaceId = stockIn.DeliverPlaceId,
                            PaperNo = stockIn.PaperNo,
                            PaperHolder = stockIn.PaperHolder,
                            CardNo = stockIn.CardNo,
                            Memo = string.Empty,
                            LogStatus = StatusEnum.已生效,
                            LogSourceBase = "NFMT",
                            LogSource = "dbo.St_StockIn",
                            SourceId = stockIn.StockInId,

                            AssetId = stockIn.AssetId,
                            CorpId = stockIn.CorpId,
                            CustomsType = stockIn.CustomType,
                            DeptId = stockIn.DeptId,
                            ProducerId = stockIn.ProducerId,
                            StockType = stockIn.StockType,
                            OriginPlaceId = stockIn.OriginPlaceId,
                            OriginPlace = stockIn.OriginPlace,
                            Format = stockIn.Format
                        };

                        DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                        result = stockLogDAL.Insert(user, stockLog);
                        if (result.ResultStatus != 0)
                            return result;

                        int stockLogId = 0;
                        if (result.ReturnValue == null || !int.TryParse(result.ReturnValue.ToString(), out stockLogId) || stockLogId == 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "流水添加失败";
                            return result;
                        }

                        //写入库登记库存关联表
                        DAL.StockInStockDAL stockInStockDAL = new StockInStockDAL();
                        result = stockInStockDAL.Insert(user, new Model.StockInStock()
                        {
                            StockInId = stockIn.StockInId,
                            StockId = stockId,
                            StockLogId = stockLogId,
                            RefStatus = StatusEnum.已生效
                        });

                        if (result.ResultStatus != 0)
                            return result;
                    }

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

            return result;
        }
Exemple #26
0
        private StringBuilder GetBanInfo(NFMT.Data.Model.Bank bank)
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<span>");

            if (bank == null || bank.BankId <= 0)
                return sb.Clear();

            switch (bank.BankName)
            {
                case "JPM":
                    sb.Append("Please transfer the following position from our account FONE to J.P.Morgan physical department:");
                    break;
                case "SBP":
                    sb.Append("Please transfer the following position from our account TRIWA2 to Standard Bank PLC");
                    break;
                case "SCB":
                    sb.Append("Please transfer the following position from our account TRIWA002 to SCB SIP’s LME account:");
                    break;
                default: break;
            }

            return sb.Length > 0 ? sb.Append("</span>").Append("<br>") : sb.Clear();
        }
Exemple #27
0
        public ResultModel PledgeApplyCreateHandle(UserModel user, NFMT.Operate.Model.Apply apply, Model.PledgeApply pledgeApply, List<Model.PledgeApplyDetail> pledgeApplyDetails)
        {
            ResultModel result = new ResultModel();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    NFMT.Operate.DAL.ApplyDAL applyDAL = new Operate.DAL.ApplyDAL();
                    result = applyDAL.Insert(user, apply);
                    if (result.ResultStatus != 0)
                        return result;

                    int applyId = (int)result.ReturnValue;
                    pledgeApply.ApplyId = applyId;

                    NFMT.WareHouse.DAL.PledgeApplyDAL pledgeApplyDAL = new PledgeApplyDAL();
                    result = pledgeApplyDAL.Insert(user, pledgeApply);
                    if (result.ResultStatus != 0)
                        return result;

                    int pledgeApplyId = (int)result.ReturnValue;

                    NFMT.WareHouse.DAL.PledgeApplyDetailDAL detailDAL = new PledgeApplyDetailDAL();
                    foreach (Model.PledgeApplyDetail detail in pledgeApplyDetails)
                    {
                        detail.PledgeApplyId = pledgeApplyId;
                        result = detailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
                result.ResultStatus = -1;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }
Exemple #28
0
        public ResultModel Audit(UserModel user, NFMT.WorkFlow.Model.DataSource dataSource, bool isPass)
        {
            ResultModel result = new ResultModel();

            try
            {
                DAL.StockDAL stockDAL = new StockDAL();
                NFMT.WareHouse.DAL.StockLogDAL stockLogDAL = new StockLogDAL();
                NFMT.WareHouse.DAL.StockReceiptDetailDAL stockReceiptDetailDAL = new StockReceiptDetailDAL();

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = this.stockreceiptDAL.Get(NFMT.Common.DefaultValue.SysUser, dataSource.RowId);
                    if (result.ResultStatus != 0)
                        return result;

                    Model.StockReceipt stockReceipt = result.ReturnValue as Model.StockReceipt;
                    if (stockReceipt == null || stockReceipt.ReceiptId <= 0)
                    {
                        result.ResultStatus = -1;
                        result.Message = "库存回执不存在";
                        return result;
                    }

                    //审核,修改数据状态
                    result = this.stockreceiptDAL.Audit(user, stockReceipt, isPass);
                    if (result.ResultStatus != 0)
                        return result;

                    //审核通过
                    if (isPass)
                    {
                        //获取回执明细
                        result = stockReceiptDetailDAL.Load(user, stockReceipt.ReceiptId);
                        if (result.ResultStatus != 0)
                            return result;

                        List<Model.StockReceiptDetail> stockReceiptDetails = result.ReturnValue as List<Model.StockReceiptDetail>;
                        if (stockReceiptDetails == null || stockReceiptDetails.Count == 0)
                        {
                            result.ResultStatus = -1;
                            result.Message = "获取回执明细失败";
                            return result;
                        }

                        foreach (Model.StockReceiptDetail detail in stockReceiptDetails)
                        {
                            //获取库存流水
                            result = stockLogDAL.Get(NFMT.Common.DefaultValue.SysUser, detail.StockLogId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.StockLog stockLog = result.ReturnValue as Model.StockLog;
                            if (stockLog == null || stockLog.StockLogId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "获取库存流水失败";
                                return result;
                            }

                            //更新库存流水回执重量
                            stockLog.GapAmount += detail.QtyMiss;
                            result = stockLogDAL.Update(user, stockLog);
                            if (result.ResultStatus != 0)
                                return result;

                            //获取库存
                            result = stockDAL.Get(user, detail.StockId);
                            if (result.ResultStatus != 0)
                                return result;

                            Model.Stock stock = result.ReturnValue as Model.Stock;
                            if (stock == null || stock.StockId <= 0)
                            {
                                result.ResultStatus = -1;
                                result.Message = "库存不存在";
                                return result;
                            }

                            //更新库存净重
                            if (stockReceipt.ReceiptType == (int)ReceiptTypeEnum.入库回执)
                            {
                                stock.ReceiptInGap += detail.QtyMiss;
                                //stock.NetAmount += detail.QtyMiss;
                            }
                            else
                                stock.ReceiptOutGap += detail.QtyMiss;
                            stock.CurNetAmount = detail.ReceiptAmount;

                            result = stockDAL.Update(user, stock);
                            if (result.ResultStatus != 0)
                                return result;
                        }
                    }

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

            return result;
        }
Exemple #29
0
        public ResultModel LoadBySubId(UserModel user, int subId, NFMT.Invoice.InvoiceTypeEnum invoiceType)
        {
            ResultModel result = new ResultModel();

            SqlDataReader dr = null;
            try
            {
                int entryStatus = (int)NFMT.Common.StatusEnum.已录入;

                string cmdText = string.Format("select bi.* from dbo.Inv_BusinessInvoice bi inner join dbo.Invoice inv on bi.InvoiceId = inv.InvoiceId where bi.SubContractId ={0} and inv.InvoiceType = {1} and inv.InvoiceStatus>={2}", subId, (int)invoiceType, entryStatus);
                dr = SqlHelper.ExecuteReader(ConnectString, CommandType.Text, cmdText, null);

                List<Model.BusinessInvoice> models = new List<BusinessInvoice>();

                int i = 0;
                while (dr.Read())
                {
                    models.Add(CreateModel<BusinessInvoice>(dr));
                    i++;
                }

                result.AffectCount = i;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = models;
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }

            return result;
        }
Exemple #30
0
        public ResultModel PledgeApplyUpdateHandle(UserModel user, NFMT.Operate.Model.Apply apply, Model.PledgeApply pledgeApply, List<Model.PledgeApplyDetail> details)
        {
            ResultModel result = new ResultModel();
            NFMT.Operate.DAL.ApplyDAL applyDAL = new NFMT.Operate.DAL.ApplyDAL();

            try
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    result = pledgeapplyDAL.Get(user, pledgeApply.PledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.Model.PledgeApply pledgeApplyRe = result.ReturnValue as NFMT.WareHouse.Model.PledgeApply;
                    if (pledgeApplyRe == null || pledgeApplyRe.PledgeApplyId <= 0)
                    {
                        result.ResultStatus = -1;
                        return result;
                    }

                    result = applyDAL.Get(user, apply.ApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.Operate.Model.Apply applyRe = result.ReturnValue as NFMT.Operate.Model.Apply;
                    if (result.ResultStatus != 0)
                        return result;
                    applyRe.EmpId = apply.EmpId;
                    applyRe.ApplyTime = apply.ApplyTime;
                    applyRe.ApplyDept = apply.ApplyDept;
                    applyRe.ApplyCorp = apply.ApplyCorp;
                    applyRe.ApplyDesc = apply.ApplyDesc;

                    //更新主申请
                    result = applyDAL.Update(user, applyRe);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.DAL.PledgeApplyDetailDAL pledgeApplyDetailDAL = new PledgeApplyDetailDAL();
                    //作废所有明细
                    result = pledgeApplyDetailDAL.InvalidAll(user, pledgeApply.PledgeApplyId);
                    if (result.ResultStatus != 0)
                        return result;

                    NFMT.WareHouse.DAL.StockDAL stockDAL = new StockDAL();
                    foreach(Model.PledgeApplyDetail detail in details)
                    {
                        //写入质押申请明细
                        detail.PledgeApplyId = pledgeApply.PledgeApplyId;
                        result = pledgeApplyDetailDAL.Insert(user, detail);
                        if (result.ResultStatus != 0)
                            return result;
                    }

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                result.ResultStatus = -1;
                result.Message = ex.Message;
            }
            finally
            {
                if (result.ResultStatus != 0)
                    log.ErrorFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
                else if (log.IsInfoEnabled)
                    log.InfoFormat("{0} {1},类型序号:{2}", user.EmpName, result.Message, result.ReturnValue);
            }

            return result;
        }