Esempio n. 1
0
        public static BorrowORLoanViewInfo BuildBorrowORLoanViewInfo(BorrowORLoanInfo info)
        {
            BorrowORLoanViewInfo viewInfo = new BorrowORLoanViewInfo();

            viewInfo.Id          = info.Id;
            viewInfo.Lender      = info.Lender;
            viewInfo.LoanAccount = info.LoanAccount;

            if (info.ReturnDate.CompareTo(new DateTime(2001, 1, 1)) > 0)
            {
                viewInfo.ReturnDate = info.ReturnDate.ToString("yyyy-MM-dd");
            }
            if (info.HappenedDate.CompareTo(new DateTime(2001, 1, 1)) > 0)
            {
                viewInfo.HappenedDate = info.HappenedDate.ToString("yyyy-MM-dd");
            }
            viewInfo.Status                = info.Status;
            viewInfo.Amount                = info.Amount;
            viewInfo.BorrowedAccount       = info.BorrowedAccount;
            viewInfo.Borrower              = info.Borrower;
            viewInfo.BorrowORLoan          = info.BorrowORLoan;
            viewInfo.BorrowORLoanAccountId = info.BorrowORLoanAccountId;
            viewInfo.BorrowORLoanType      = info.BorrowORLoanType;
            viewInfo.Content               = info.Content;
            return(viewInfo);
        }
Esempio n. 2
0
        public static int DeleteLoanById(int id)
        {
            int iSuccess = 0;
            int uSuccess = 0;

            BorrowORLoanInfo loanInfo = LoanDAL.GetLoanById(id);
            UserInfo         userInfo = UserDAL.GetUserByName(loanInfo.Lender);

            LoanDAL.DeleteLoanById(id, out iSuccess);

            if (iSuccess > 0)
            {
                if (loanInfo.BorrowORLoanType == 2)
                {
                    CardInfo cardInfo   = CardDAL.GetCardByCardNumber(loanInfo.Lender, userInfo.Id);
                    float    amount     = cardInfo.Amount - loanInfo.Amount;
                    float    LoanAmount = cardInfo.LoanAmount - loanInfo.Amount;
                    CardDAL.UpdateCardAmount(amount, LoanAmount, cardInfo.Id, 4, out uSuccess);
                }
            }
            if (iSuccess > 0 && ((loanInfo.BorrowORLoanType == 2 && uSuccess > 0) || (loanInfo.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 3
0
        public static int DeleteBorrowedById(int id)
        {
            int iSuccess = 0;
            int uSuccess = 0;

            BorrowORLoanInfo borrowInfo = BorrowDAL.GetBorrowById(id);
            UserInfo         userInfo   = UserDAL.GetUserByName(borrowInfo.Borrower);

            BorrowDAL.DeleteBorrowed(id, out iSuccess);

            if (iSuccess > 0)
            {
                if (borrowInfo.BorrowORLoanType == 2)
                {
                    CardInfo cardInfo     = CardDAL.GetCardByCardNumber(borrowInfo.BorrowedAccount, userInfo.Id);
                    float    amount       = cardInfo.Amount - borrowInfo.Amount;
                    float    borrowAmount = cardInfo.BorrowAmount - borrowInfo.Amount;
                    CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
                }
            }
            if (iSuccess > 0 && ((borrowInfo.BorrowORLoanType == 2 && uSuccess > 0) || (borrowInfo.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 4
0
        protected void btnLoanAddSubmit_Click(object sender, EventArgs e)
        {
            BorrowORLoanInfo loanInfo = new BorrowORLoanInfo();

            if (!string.IsNullOrEmpty(this.HiddenField1.Value.Trim()))
            {
                loanInfo.Id = Convert.ToInt32(this.HiddenField1.Value.Trim());
            }
            else
            {
                loanInfo.Id = 0;
            }
            #region 验证
            if (!CheckLoanAddForm())
            {
                string type = this.RadioLoanAddLoanType.SelectedValue;
                string temp = this.HidderField2.Value;
                this.ClientScript.RegisterStartupScript(this.GetType(), "fillForm", "DisplayAddLoandiv('" + type + "');fillFormField({loanAccount:'" + temp + "'});", true);
                return;
            }
            #endregion

            loanInfo.Borrower = this.txtLoanAddBorrower.Text.Trim();
            if (this.RadioLoanAddLoanType.SelectedValue == "2" && !string.IsNullOrEmpty(this.HidderField2.Value.Trim()))
            {
                string[] s        = this.HidderField2.Value.Split(',');
                CardInfo cardInfo = CardMethods.GetCardById(Convert.ToInt32(s[0]));
                loanInfo.LoanAccount           = cardInfo.CardNumber;
                loanInfo.BorrowORLoanAccountId = cardInfo.Id;
            }
            loanInfo.Lender           = this.txtLoanAddLender.Text.Trim();
            loanInfo.BorrowedAccount  = this.txtLoanAddBorrowAccount.Text.Trim();
            loanInfo.BorrowORLoanType = Convert.ToInt32(this.RadioLoanAddLoanType.SelectedValue);
            loanInfo.Amount           = Convert.ToSingle(this.txtLoanAddLoanAmount.Text.Trim());
            loanInfo.HappenedDate     = HelperCommon.ConverToDateTime(string.Format("{0:d}", this.txtLoanAddLoanDate.Text.Trim()));
            if (!string.IsNullOrEmpty(this.txtLoanAddReturnDate.Text.Trim()))
            {
                loanInfo.ReturnDate = HelperCommon.ConverToDateTime(string.Format("{0:d}", this.txtLoanAddReturnDate.Text.Trim()));
            }
            loanInfo.Status  = Convert.ToInt32(this.dropLoanAddStatus.SelectedValue);
            loanInfo.Content = this.txtLoanAddContent.Text.Trim();

            int iSuccess = LoanMethods.InsertOrUpdatetoLoan(loanInfo);
            this.ClientScript.RegisterStartupScript(this.GetType(), "", "DisplayAddLoandiv();", true);
            if (iSuccess == 1)
            {
                Alert.Show(this, "新增一条收入成功!");
            }
            else if (iSuccess == 2)
            {
                Alert.Show(this, "修改成功!");
            }
            else
            {
                Alert.Show(this, "操作失败!");
            }
            queryList = new List <QueryElement>();
            BindLoanListDataGrid(queryList);
        }
Esempio n. 5
0
        public static BorrowORLoanViewInfo GetBorrowInfo(string Id)
        {
            BorrowORLoanInfo     info     = BorrowedMethods.GetBorrowById(Convert.ToInt32(Id));
            BorrowORLoanViewInfo viewInfo = ViewInfoUtils.BuildBorrowORLoanViewInfo(info);

            viewInfo.BorrowedAccountList = getLoanAccountByPerson(viewInfo.Borrower);
            return(viewInfo);
        }
Esempio n. 6
0
        /// <summary>
        /// 新增或修改
        /// </summary>
        /// <param name="mySqlTransaction"></param>
        /// <param name="info"></param>
        /// <param name="iSuccess"></param>
        public static void InsertOrUpdatetoBorrowed(BorrowORLoanInfo info, out int iSuccess)
        {
            StringBuilder sb = new StringBuilder();

            if (info.Id > 0)
            {
                sb.Append(" update borrowing set BorrowORLoanType = @BorrowORLoanType,BorrowORLoanAccountId=@BorrowORLoanAccountId,BorrowedAccount = @BorrowedAccount,LoanAccount=@LoanAccount,");
                sb.Append("Lender = @Lender,Amount = @Amount,HappenedDate = @HappenedDate,ReturnDate = @ReturnDate,Status=@Status,Content = @Content ");
                sb.Append(" where Id = @Id ");
            }
            else
            {
                sb.Append(" insert into borrowing (borrowORLoan,BorrowORLoanType,BorrowORLoanAccountId,BorrowedAccount,Borrower,LoanAccount,Lender,Amount,HappenedDate,ReturnDate,Status,Content) ");
                sb.Append(" Values (@borrowORLoan,@BorrowORLoanType,@BorrowORLoanAccountId,@BorrowedAccount,@Borrower,@LoanAccount,@Lender,@Amount,@HappenedDate,@ReturnDate,@Status,@Content) ");
            }
            MySqlParameter[] pars = new MySqlParameter[]
            {
                new MySqlParameter("@Id", MySqlDbType.Int32),
                new MySqlParameter("@borrowORLoan", MySqlDbType.Int32),
                new MySqlParameter("@BorrowORLoanType", MySqlDbType.Int32),
                new MySqlParameter("@BorrowORLoanAccountId", MySqlDbType.Int32),
                new MySqlParameter("@BorrowedAccount", MySqlDbType.String),
                new MySqlParameter("@Borrower", MySqlDbType.String),
                new MySqlParameter("@LoanAccount", MySqlDbType.String),
                new MySqlParameter("@Lender", MySqlDbType.String),
                new MySqlParameter("@Amount", MySqlDbType.Float),
                new MySqlParameter("@HappenedDate", MySqlDbType.DateTime),
                new MySqlParameter("@ReturnDate", MySqlDbType.DateTime),
                new MySqlParameter("@Status", MySqlDbType.Int32),
                new MySqlParameter("@Content", MySqlDbType.String)
            };
            pars[0].Value = info.Id;
            pars[1].Value = 1;
            pars[2].Value = info.BorrowORLoanType;
            pars[3].Value = info.BorrowORLoanAccountId;
            pars[4].Value = info.BorrowedAccount;
            pars[5].Value = info.Borrower;
            //pars[4].Value = info.LoanType;
            pars[6].Value  = info.LoanAccount;
            pars[7].Value  = info.Lender;
            pars[8].Value  = info.Amount;
            pars[9].Value  = info.HappenedDate;
            pars[10].Value = info.ReturnDate;
            pars[11].Value = info.Status;
            pars[12].Value = info.Content;
            iSuccess       = MySqlDBHelper.ExecuteCommand(sb.ToString(), pars);
        }
Esempio n. 7
0
        public static BorrowORLoanInfo GetBorrowById(int id)
        {
            BorrowORLoanInfo borrowInfo = new BorrowORLoanInfo();
            StringBuilder    sb         = new StringBuilder();

            sb.Append(" select * from borrowing where id = @Id ");
            MySqlParameter par = new MySqlParameter("@Id", MySqlDbType.Int32);

            par.Value = id;
            using (MySqlDataReader reader = MySqlDBHelper.GetReader(sb.ToString(), par))
            {
                while (reader.Read())
                {
                    borrowInfo = new BorrowORLoanInfo(reader);
                }
            }
            return(borrowInfo);
        }
Esempio n. 8
0
        public static int InsertOrUpdatetoLoan(BorrowORLoanInfo info)
        {
            int iSuccess = 0;
            int uSuccess = 0;
            BorrowORLoanInfo loanInfo = new BorrowORLoanInfo();
            UserInfo         userInfo = UserDAL.GetUserByName(info.Lender);
            CardInfo         cardInfo = CardDAL.GetCardByCardNumber(info.LoanAccount, userInfo.Id);

            if (info.Id > 0)
            {
                loanInfo = LoanDAL.GetLoanById(info.Id);
            }
            LoanDAL.InsertOrUpdatetoLoan(info, out iSuccess);
            if (iSuccess > 0 && info.BorrowORLoanType == 2)
            {
                float amount     = 0;
                float loanAmount = 0;
                if (info.Id > 0)
                {
                    amount     = cardInfo.Amount + (info.Amount - loanInfo.Amount);
                    loanAmount = cardInfo.Amount + (info.Amount - loanInfo.Amount);
                }
                else
                {
                    amount     = cardInfo.Amount + info.Amount;
                    loanAmount = cardInfo.Amount + info.Amount;
                }
                CardDAL.UpdateCardAmount(amount, loanAmount, cardInfo.Id, 4, out uSuccess);
            }

            if ((iSuccess > 0 && info.Id > 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(2);
            }
            else if ((iSuccess > 0 && info.Id == 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 9
0
        public static int InsertOrUpdatetoBorrowed(BorrowORLoanInfo info)
        {
            int iSuccess = 0;
            int uSuccess = 0;
            BorrowORLoanInfo borrowInfo = new BorrowORLoanInfo();
            UserInfo         userInfo   = UserDAL.GetUserByName(info.Borrower);
            CardInfo         cardInfo   = CardDAL.GetCardByCardNumber(info.BorrowedAccount, userInfo.Id);

            if (info.Id > 0)
            {
                borrowInfo = BorrowDAL.GetBorrowById(info.Id);
            }
            BorrowDAL.InsertOrUpdatetoBorrowed(info, out iSuccess);
            if (iSuccess > 0 && info.BorrowORLoanType == 2)
            {
                float amount       = 0;
                float borrowAmount = 0;
                if (info.Id > 0)
                {
                    amount       = cardInfo.Amount + (info.Amount - borrowInfo.Amount);
                    borrowAmount = cardInfo.BorrowAmount + (info.Amount - borrowInfo.Amount);
                }
                else
                {
                    amount       = cardInfo.Amount + info.Amount;
                    borrowAmount = cardInfo.BorrowAmount + info.Amount;
                }
                CardDAL.UpdateCardAmount(amount, borrowAmount, cardInfo.Id, 3, out uSuccess);
            }

            if ((iSuccess > 0 && info.Id > 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(2);
            }
            else if ((iSuccess > 0 && info.Id == 0) && ((info.BorrowORLoanType == 2 && uSuccess > 0) || (info.BorrowORLoanType != 2 && uSuccess == 0)))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Esempio n. 10
0
 public static int InsertOrUpdatetoLoan(BorrowORLoanInfo info)
 {
     return(LoanProxy.InsertOrUpdatetoLoan(info));
 }
Esempio n. 11
0
 public static int InsertOrUpdatetoBorrowed(BorrowORLoanInfo info)
 {
     return(BorrowProxy.InsertOrUpdatetoBorrowed(info));
 }