Ejemplo n.º 1
0
        public void Delete(LPWeb.Model.LoanContacts model)
        {
            if ((model.FileId <= 0) || (model.ContactRoleId <= 0))
            {
                return;
            }
            string strSql = string.Format("delete from LoanContacts  where FileId={0} and ContactRoleId={1} ", model.FileId, model.ContactRoleId);

            if (model.ContactId >= 0)
            {
                strSql += " and ContactId=" + model.ContactId;
            }

            DbHelperSQL.ExecuteSql(strSql);
        }
Ejemplo n.º 2
0
 public void Reassign(LPWeb.Model.LoanContacts oldModel, LPWeb.Model.LoanContacts model, int UserId)
 {
     SqlParameter[] parameters =
     {
         new SqlParameter("@FileId",        SqlDbType.Int, 4),
         new SqlParameter("@NewContactId",  SqlDbType.Int, 4),
         new SqlParameter("@OldContactId",  SqlDbType.Int, 4),
         new SqlParameter("@ContactRoleId", SqlDbType.Int, 4),
         new SqlParameter("@Requester",     SqlDbType.Int, 4)
     };
     parameters[0].Value = model.FileId;
     parameters[1].Value = model.ContactId;
     parameters[2].Value = oldModel.ContactId;
     parameters[3].Value = model.ContactRoleId;
     parameters[4].Value = UserId;
     DbHelperSQL.RunProcedure("dbo.lpsp_ReassignLoanContact", parameters);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(LPWeb.Model.LoanContacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into LoanContacts(");
            strSql.Append("FileId,ContactRoleId,ContactId)");
            strSql.Append(" values (");
            strSql.Append("@FileId,@ContactRoleId,@ContactId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileId",        SqlDbType.Int, 4),
                new SqlParameter("@ContactRoleId", SqlDbType.Int, 4),
                new SqlParameter("@ContactId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FileId;
            parameters[1].Value = model.ContactRoleId;
            parameters[2].Value = model.ContactId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(LPWeb.Model.LoanContacts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update LoanContacts set ");
            strSql.Append("FileId=@FileId,");
            strSql.Append("ContactRoleId=@ContactRoleId,");
            strSql.Append("ContactId=@ContactId");
            strSql.Append(" where FileId=@FileId and ContactRoleId=@ContactRoleId and ContactId=@ContactId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileId",        SqlDbType.Int, 4),
                new SqlParameter("@ContactRoleId", SqlDbType.Int, 4),
                new SqlParameter("@ContactId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.FileId;
            parameters[1].Value = model.ContactRoleId;
            parameters[2].Value = model.ContactId;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public LPWeb.Model.LoanContacts GetModel(int FileId, int ContactRoleId, int ContactId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 FileId,ContactRoleId,ContactId from LoanContacts ");
            strSql.Append(" where FileId=@FileId and ContactRoleId=@ContactRoleId and ContactId=@ContactId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FileId",        SqlDbType.Int, 4),
                new SqlParameter("@ContactRoleId", SqlDbType.Int, 4),
                new SqlParameter("@ContactId",     SqlDbType.Int, 4)
            };
            parameters[0].Value = FileId;
            parameters[1].Value = ContactRoleId;
            parameters[2].Value = ContactId;

            LPWeb.Model.LoanContacts model = new LPWeb.Model.LoanContacts();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["FileId"].ToString() != "")
                {
                    model.FileId = int.Parse(ds.Tables[0].Rows[0]["FileId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ContactRoleId"].ToString() != "")
                {
                    model.ContactRoleId = int.Parse(ds.Tables[0].Rows[0]["ContactRoleId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ContactId"].ToString() != "")
                {
                    model.ContactId = int.Parse(ds.Tables[0].Rows[0]["ContactId"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Link button click event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLink_Click(object sender, EventArgs e)
        {
            string sLoanIds  = this.hdLoanIds.Value;
            string sLinkType = this.hdLinkType.Value;
            int    iLinkType = 1;

            if (sLoanIds.Length < 1)
            {
                return;
            }

            try
            {
                LPWeb.BLL.ContactRoles contactRoles = new LPWeb.BLL.ContactRoles();
                DataSet dsRole = contactRoles.GetList("Name='" + sLinkType + "'");
                if (dsRole.Tables.Count > 0 && dsRole.Tables[0].Rows.Count > 0)
                {
                    iLinkType = Convert.ToInt32(dsRole.Tables[0].Rows[0]["ContactRoleId"].ToString());
                }
                LPWeb.BLL.LoanContacts loanContact = new LPWeb.BLL.LoanContacts();
                foreach (string sLoanID in sLoanIds.Split(','))
                {
                    if (sLoanID.Trim() == "")
                    {
                        continue;
                    }
                    int iLoanID       = 0;
                    int iOldContactID = 0;
                    if (sLoanID == "" || Int32.TryParse(sLoanID, out iLoanID) == false)
                    {
                        continue;
                    }
                    DataSet dsloancontact = loanContact.GetList("FileId=" + sLoanID + " AND ContactRoleId=" + iLinkType.ToString());
                    if (dsloancontact.Tables.Count > 0 && dsloancontact.Tables[0].Rows.Count > 0)
                    {
                        iOldContactID = Convert.ToInt32("0" + dsloancontact.Tables[0].Rows[0]["ContactId"].ToString());
                    }
                    LPWeb.Model.LoanContacts modelOld = loanContact.GetModel(iLoanID, iLinkType, iOldContactID);
                    if (modelOld == null)
                    {
                        modelOld           = new Model.LoanContacts();
                        modelOld.ContactId = 0;
                    }
                    LPWeb.Model.LoanContacts model = new LPWeb.Model.LoanContacts();
                    model.FileId        = iLoanID;
                    model.ContactRoleId = iLinkType;
                    model.ContactId     = this.iProspectID;
                    loanContact.Reassign(modelOld, model, 0);

                    ServiceManager sm = new ServiceManager();
                    using (LP2ServiceClient service = sm.StartServiceClient())
                    {
                        UpdateBorrowerRequest req = new UpdateBorrowerRequest();
                        req.hdr = new ReqHdr();
                        req.hdr.SecurityToken = "SecurityToken";
                        req.hdr.UserId        = this.CurrUser.iUserID;
                        req.ContactId         = model.ContactId;

                        UpdateBorrowerResponse respone = null;

                        try
                        {
                            respone = service.UpdateBorrower(req);
                        }
                        catch (System.ServiceModel.EndpointNotFoundException)
                        {
                            string sExMsg = string.Format("Exception happened when  Update loan (ContactId={0}): {1}", model.ContactId, "Point Manager is not running.");
                            LPLog.LogMessage(LogType.Logerror, sExMsg);
                        }
                        catch (Exception ex)
                        {
                            string sExMsg = string.Format("Exception happened when  Update loan (ContactId={0}): {1}", model.ContactId, ex.Message);
                            LPLog.LogMessage(LogType.Logerror, sExMsg);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LPLog.LogMessage(LogType.Logdebug, ex.ToString());
                PageCommon.WriteJsEnd(this, "Failed to link the selected loans.", this.sCloseDialogCodes + this.sRefreshCodes);
            }

            this.hdLoanIds.Value  = string.Empty;
            this.hdLinkType.Value = string.Empty;

            // success
            PageCommon.WriteJsEnd(this, "Link the selected loans successfully.", this.sCloseDialogCodes + this.sRefreshCodes);
        }