Exemple #1
0
        public static ProductModel Convert2Product(DataRow dr, DataRow[] listCustomRows, decimal money, int term)
        {
            ProductModel p;
            p = new ProductModel();
            p.ProductCode = dr["sProductCode"].ToString();
            p.ProductType = dr["sProductType"].ToString();
            p.ProductName = dr["sProductName"].ToString();
            p.OrganID = dr["sOrganID"].ToString();
            p.OrganName = dr["sOrganName"].ToString();
            p.AnnualRate = dr["dAnnualRate"] is DBNull ? 0m : Convert.ToDecimal(dr["dAnnualRate"]);

            p.RepaymentType = dr["sRepaymentType"].ToString();
            p.ApplyCondition = dr["sApplyCondition"].ToString();
            p.RequiredFile = dr["sRequiredFile"].ToString();
            p.Memo = dr["sMemo"].ToString();
            p.Details = dr["sDetails"].ToString();

            p.OrganLogo = "../photos/" + dr["sLogo"].ToString();
            p.Chars = dr["sChars"].ToString();

            //小潮started here
            p.MoneyTop = dr["dMoneyTop"] is DBNull ? 0m : Convert.ToInt32(dr["dMoneyTop"]) / 10000;   //便于显示,不知道怎么去掉decimal后面的小数点,所以用了int32
            p.MoneyBottom = dr["dMoneyBottom"] is DBNull ? 0m : Convert.ToInt32(dr["dMoneyBottom"]) / 10000;
            p.TermTop = dr["nTermTop"] is DBNull ? 0 : Convert.ToInt32(dr["nTermTop"]);
            p.TermBottom = dr["nTermBottom"] is DBNull ? 0 : Convert.ToInt32(dr["nTermBottom"]);
            p.RepaymentTypeDisplay = DisplayRepaymentType(dr["sRepaymentType"].ToString());
            p.GetLoanDays = dr["nGetLoanDays"] is DBNull ? 0 : Convert.ToInt32(dr["nGetLoanDays"]);
            p.ServerFeeMonthly = dr["dServerFeeMonthly"] is DBNull ? 0m : Convert.ToDecimal(dr["dServerFeeMonthly"]);
            p.ServerFeeOnce = dr["dServerFeeOnce"] is DBNull ? 0m : Convert.ToDecimal(dr["dServerFeeOnce"]);
            p.TotalFeeDisplay = TotalFee(p.ServerFeeOnce, p.ServerFeeMonthly, p.AnnualRate, money, term).ToString("F2");
            p.FeesDetail = Feesdetail(p.ServerFeeOnce, p.ServerFeeMonthly, p.AnnualRate);

            p.RepaymentMonthly = CalcRepaymentMonthly(p.RepaymentType,p.AnnualRate, money, term,p.ServerFeeMonthly).ToString("F2");   //每月偿还金额
            p.AnnualRateDisplay = ((p.AnnualRate + p.ServerFeeMonthly * 12) * 100).ToString("F1") + "%";
            //end here

            CustomModel c;
            foreach (DataRow drCustom in listCustomRows)
            {
                c = new CustomModel();
                c.CustomName = drCustom["sCustomName"].ToString();
                c.OrganName = drCustom["sOrganName"].ToString();
                p.Customs.Add(c);
            }
            return p;
        }
        public ActionResult ProductCustomer(string productcode)
        {
            string sql = "select t1.sCustomName,t1.sCellPhone,t1.sOrganID,t1.sEmail,t2.sOrganName " +
                " from T_Custom t1 " +
                " inner join T_ForeignOrgan t2 on t1.sOrganID=t2.sOrganID " +
                " where t2.sOrganID in(select sOrganID from T_Product where sProductCode='" + productcode + "')";
            DA_Common da=new DA_Common();
            DataSet ds = da.CommonQuery(sql);

            List<CustomModel> arrCustoms = new List<CustomModel>();
            CustomModel m;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                m = new CustomModel();
                m.CellPhone = dr["sCellPhone"].ToString();
                m.CustomName = dr["sCustomName"].ToString();
                m.Email = dr["sEmail"].ToString();
                m.OrganID = dr["sOrganID"].ToString();
                m.OrganName = dr["sOrganName"].ToString();

                arrCustoms.Add(m);
            }

            return View(arrCustoms);
        }
        CustomModel GetCustomModel()
        {
            Message.CustomInfo loginUser = Session["loginedcustom"] as Message.CustomInfo;
            string sql1 = "select t1.sEmail,t1.sCustomName,t1.sCertState,t1.sSex,t1.dtBirthday,t1.sCellPhone,t1.sOrganID,t1.sWorkYears, " +
                "t1.sOrganAddress,t1.sOrganDpt,t1.sAddress," +
                "t2.sOrganName " +
                " from t_custom t1 " +
                " left join t_foreignorgan t2 on t1.sorganid=t2.sorganid " +
                " where t1.sCustomID='" + loginUser.CustomID + "'";
            string sql2 = " select t1.sProductCode,t1.sProductName,t1.sOrganID, t1.sProductType, t1.dAnnualRate, t1.sApplyCondition, t1.sRequiredFile, t1.sMemo, t1.sDetails,t1.sRepaymentType,t1.sChars," +
                          "t1.dMoneyTop,t1.dMoneyBottom," +
                          "t1.nTermTop, t1.nTermBottom," +
                          "t1.nGetLoanDays,t1.dServerFeeOnce,t1.dServerFeeMonthly," +
                          " t2.sOrganName, t2.sLogo" +
                          " from T_Product t1" +
                          " left join T_ForeignOrgan t2 on t1.sOrganID=t2.sOrganID" +
                          " where t1.sOrganID='" + loginUser.OrganID + "'";
            string sql3 = "select t1.*," +
                "t2.aaa103 as sProductTypeName " +
                " from t_applyrecord t1 " +
                " left join aa10 t2 on t1.sProductType=t2.aaa102 and t2.aaa100='sProductType'" +
                " inner join t_product t3 on t1.sProductCode=t3.sProductCode and t3.sOrganID='" + loginUser.OrganID + "'";

            DA_Adapter da = new DA_Adapter();
            DataSet ds = new DataSet();
            string err = "";
            da.Common_Query_MultiTable(ref ds, sql1, "T_Custom", sql2, "T_Product", sql3, "T_ApplyRecord", ref err);

            DataRow drCustom = ds.Tables["T_Custom"].Rows[0];
            CustomModel m = new CustomModel();

            m.CellPhone = drCustom["sCellPhone"] is DBNull ? "" : drCustom["sCellPhone"].ToString();
            m.CustomID = loginUser.CustomID;
            m.CustomName = drCustom["sCustomName"] is DBNull ? "" : drCustom["sCustomName"].ToString();
            m.CertState = drCustom["sCertState"] is DBNull ? "" : drCustom["sCertState"].ToString();
            m.CertStateDisplay = ToCertState(m.CertState);

            m.DateOfBirth = drCustom["dtBirthday"] is DBNull ? "" : Convert.ToDateTime(drCustom["dtBirthday"]).ToString("yyyy-MM-dd");
            m.Email = drCustom["sEmail"] is DBNull ? "" : drCustom["sEmail"].ToString();
            m.Occupation = "";
            m.OrganAddress = drCustom["sAddress"] is DBNull ? "" : drCustom["sAddress"].ToString();
            m.OrganID = drCustom["sOrganID"] is DBNull ? "" : drCustom["sOrganID"].ToString();
            m.OrganName = drCustom["sOrganName"] is DBNull ? "" : drCustom["sOrganName"].ToString();
            m.Sex = drCustom["sSex"] is DBNull ? "" : drCustom["sSex"].ToString();
            m.WorkingAge = drCustom["sWorkYears"] is DBNull ? "" : drCustom["sWorkYears"].ToString();

            m.Address = drCustom["sAddress"] is DBNull ? "" : drCustom["sAddress"].ToString();
            m.WorkYears = drCustom["sWorkYears"] is DBNull ? "" : drCustom["sWorkYears"].ToString();
            m.OrganDpt = drCustom["sOrganDpt"] is DBNull ? "" : drCustom["sOrganDpt"].ToString();

            #region 加载产品列表
            DataRow[] listCustomRows;
            ProductModel p;
            decimal dYuanMoney = 100000;
            int term = 12;
            foreach (DataRow drProduct in ds.Tables["T_Product"].Rows)
            {
                listCustomRows = ds.Tables["T_Custom"].Select("sOrganID='" + drCustom["sOrganID"].ToString() + "'");
                p = BizCommon.Convert2Product(drProduct, listCustomRows, dYuanMoney, term);
                m.ProductList.Add(p);//未分页显示。
            }

            #endregion

            #region 加载申请列表

            ApplyingRecord apply;
            foreach (DataRow drApply in ds.Tables["T_ApplyRecord"].Rows)
            {
                apply = new ApplyingRecord();
                apply.CarCustomerMonthlySalary = drApply["dCarCustomerMonthlySalary"] is DBNull ? 0 : Convert.ToDecimal(drApply["dCarCustomerMonthlySalary"]);
                apply.CarProperty = drApply["sCarProperty"] is DBNull ? "" : drApply["sCarProperty"].ToString();
                apply.CarPurchasingPeriod = drApply["sCarPurchasingPeriod"] is DBNull ? "" : drApply["sCarPurchasingPeriod"].ToString();
                apply.CaseState = drApply["sCaseState"] is DBNull ? "" : drApply["sCaseState"].ToString();
                apply.CreatTime = drApply["dtCreatTime"] is DBNull ? "" : drApply["dtCreatTime"].ToString();
                apply.CustomerEmail = drApply["sCustomerEmail"] is DBNull ? "" : drApply["sCustomerEmail"].ToString();
                apply.CustomerName = drApply["sCustomerName"] is DBNull ? "" : drApply["sCustomerName"].ToString();
                apply.CustomerPhone = drApply["sCustomerPhone"] is DBNull ? "" : drApply["sCustomerPhone"].ToString();
                apply.FirmAccountBill = drApply["dFirmAccountBill"] is DBNull ? 0 : Convert.ToDecimal(drApply["dFirmAccountBill"]);
                apply.FirmAge = drApply["sFirmAge"] is DBNull ? "" : drApply["sFirmAge"].ToString();
                apply.FirmProperty = drApply["sFirmProperty"] is DBNull ? "" : drApply["sFirmProperty"].ToString();
                apply.FirmType = drApply["sFirmType"] is DBNull ? "" : drApply["sFirmType"].ToString();
                apply.HouseIncome = drApply["sHouseIncome"] is DBNull ? "" : drApply["sHouseIncome"].ToString();
                apply.HouseLocalorNot = drApply["sHouseLocalorNot"] is DBNull ? "" : drApply["sHouseLocalorNot"].ToString();
                apply.HouseNew = drApply["sHouseNew"] is DBNull ? "" : drApply["sHouseNew"].ToString();
                apply.HouseType = drApply["sFirmType"] is DBNull ? "" : drApply["sFirmType"].ToString();
                apply.PerslCardNo = drApply["sPerslCardNo"] is DBNull ? "" : drApply["sPerslCardNo"].ToString();
                apply.PerslCreditAllowance = drApply["sPerslCreditAllowance"] is DBNull ? "" : drApply["sPerslCreditAllowance"].ToString();
                apply.PerslCreditDue = drApply["sPerslCreditDue"] is DBNull ? "" : drApply["sPerslCreditDue"].ToString();
                apply.PerslCreditOwner = drApply["sPerslCreditOwner"] is DBNull ? "" : drApply["sPerslCreditOwner"].ToString();
                apply.PerslEmployment = drApply["sPerslEmployment"] is DBNull ? "" : drApply["sPerslEmployment"].ToString();
                apply.PerslLoan = drApply["sPerslLoan"] is DBNull ? "" : drApply["sPerslLoan"].ToString();
                apply.PerslLoanDue = drApply["sPerslLoanDue"] is DBNull ? "" : drApply["sPerslLoanDue"].ToString();
                apply.PerslLoanSucc = drApply["sPerslLoanSucc"] is DBNull ? "" : drApply["sPerslLoanSucc"].ToString();
                apply.PerslSalaryType = drApply["sPerslSalaryType"] is DBNull ? "" : drApply["sPerslSalaryType"].ToString();
                apply.PerslWorkingAge = drApply["sPerslWorkingAge"] is DBNull ? "" : drApply["sPerslWorkingAge"].ToString();
                apply.PerslYoBirth = drApply["sPerslYoBirth"] is DBNull ? "" : drApply["sPerslYoBirth"].ToString();
                apply.ProductCode = drApply["sProductCode"] is DBNull ? "" : drApply["sProductCode"].ToString();
                apply.ProductType = drApply["sProductType"] is DBNull ? "" : drApply["sProductType"].ToString();

                m.ApplyingRecordList.Add(apply);
            }

            #endregion

            return m;
        }
 public ActionResult CustomApply()
 {
     DataSet ds = new DataSet();
     DataRow dr = ds.Tables[0].Rows[0];
     CustomModel c = new CustomModel();
     c.CustomName = dr["SCustomName"].ToString();
     c.CellPhone = dr["sCellPhone"].ToString();
     c.OrganID = dr["sOrganID"].ToString();
     c.OrganName = dr["sOrganName"].ToString();
     c.Email = dr["sEmail"].ToString();
     c.Pwd = dr["sPwd"].ToString();
     return View();
 }
        public ActionResult MyInfoEdit_Basic(FormCollection values)
        {
            if (Session["loginedcustom"] == null)
            {
                return RedirectToAction("Login", "Account");
            }
            Message.CustomInfo loginUser = Session["loginedcustom"] as Message.CustomInfo;

            CustomModel m = new CustomModel();
            m.CustomName = (values["sCustomName"] == null ? "" : values["sCustomName"].ToString());
            m.Sex = (values["sSex"] == null ? "" : values["sSex"].ToString());
            m.Birthday = ((values["dtBirthday"] == null || values["dtBirthday"].ToString() == "") ? Convert.ToDateTime("1900-01-01") : Convert.ToDateTime(values["dtBirthday"]));
            m.Address = (values["sAddress"] == null ? "" : values["sAddress"].ToString());
            m.CellPhone = (values["sCellPhone"] == null ? "" : values["sCellPhone"].ToString());
            m.Email = (values["sEmail"] == null ? "" : values["sEmail"].ToString());
            m.OrganAddress = (values["sOrganAddress"] == null ? "" : values["sOrganAddress"].ToString());
            m.OrganName = (values["sOrganName"] == null ? "" : values["sOrganName"].ToString());
            m.WorkYears = (values["sWorkYears"] == null ? "" : values["sWorkYears"].ToString());
            m.OrganDpt = (values["sOrganDpt"] == null ? "" : values["sOrganDpt"].ToString());

            string sql = "update T_Custom set " +
                    "sCustomName=" + "'" + m.CustomName + "'" +
                    ",sSex=" + "'" + m.Sex + "'" +
                    ",dtBirthday=" + ((m.Birthday.Year == 1 || m.Birthday.Year == 1900) ? "null" : "'" + m.Birthday.ToString("yyyy-MM-dd") + "'") +
                    ",sAddress=" + "'" + m.Address + "'" +
                    ",sCellPhone=" + "'" + m.CellPhone + "'" +
                    ",sEmail=" + "'" + m.Email + "'" +
                    ",sOrganAddress=" + "'" + m.OrganAddress + "'" +
                    ",sOrganName=" + "'" + m.OrganName + "'" +
                    ",sWorkYears=" + "'" + m.WorkYears + "'" +
                    ",sOrganDpt=" + "'" + m.OrganDpt + "'" +
                    " where sCustomID=" + "'" + loginUser.CustomID + "'";

            DA_Adapter da = new DA_Adapter();
            if (da.Common_Excute(sql) == 0)
            {
                //成功
                CustomModel model = GetCustomModel();
                return View("MyInfo", model);
            }
            else
            {
                //失败
                ModelState.AddModelError("", "保存失败。");
                CustomModel model = GetCustomModel();
                return View(model);
            }
        }