Exemplo n.º 1
0
        public bool SaveRzInfo(RzInfo rzi)
        {
            if (rzi.Id > 0)
            {
                return(UpdateRzInfo(rzi));
            }
            bool isDyw = false;

            if (rzi.dywdesc.Trim() != "" && rzi.dywdesc != null)
            {
                isDyw = true;
            }
            var sql = string.Format(@"select EnterpriseId from SysUser where UserName='******'", rzi.UserName.Trim());
            var ent = DBHelper.GetScalar(sql) as int?;

            if (ent == null)
            {
                return(false);
            }
            sql = @"
insert into RZDemandInfo (Quota,TermId,PurposeId,HadCollateral,CollateralDesc)
values(@qua,@tem,@pup,@hc,@cd)
SELECT @@IDENTITY";
            var demid = DBHelper.GetScalar(sql,
                                           new SqlParameter("@qua", rzi.RZED),
                                           new SqlParameter("@tem", rzi.RZQX),
                                           new SqlParameter("@pup", rzi.RZQT),
                                           new SqlParameter("@hc", isDyw),
                                           new SqlParameter("@cd", rzi.dywdesc.Trim()));

            if (demid == null)
            {
                return(false);
            }
            sql = @"
insert into RZFlow(EnterpriseId,BankIds,FinanceId,DemandId,[Status])
values(@ent,@bks,(select top 1 Id from RZFinance where EnterpriseId=@ent),@dm,0)";
            var efc = DBHelper.Execute(sql,
                                       new SqlParameter("@ent", ent),
                                       new SqlParameter("@bks", rzi.RZYH),
                                       new SqlParameter("@dm", demid));

            if (efc > 0)
            {
                List <string> phonelist = new List <string>();
                sql = "select Phone from SysUser where RolesID = 2";
                DataTable dt = DBHelper.GetDataSet(sql);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string Phone = dr[0].ToString();
                        phonelist.Add(Phone);
                    }
                }
                sql = string.Format(@"select Phone from Bank a right join LiaisonanMan b on a.Id = b.BankId where 1=1 and b.IsDeleteed = 0 and a.ParentBankId in({0})", rzi.RZYH);
                DataTable yhdt = DBHelper.GetDataSet(sql);
                if (yhdt.Rows.Count > 0)
                {
                    foreach (DataRow yhdr in yhdt.Rows)
                    {
                        string Phone = yhdr[0].ToString();
                        phonelist.Add(Phone);
                    }
                }
                SmsService sms = new SmsService();
                for (int h = 0; h < phonelist.Count; h++)
                {
                    sms.Send(phonelist[h].ToString(), "有新的融资申请,请及时登陆镇江融资平台查看详细信息");
                }
            }
            return(efc > 0);
        }