Пример #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;
        }
        public BorrowORLoanInfo Get(long id)
        {
            if (indexerForPrimaryKeys == null || innerListChanged)
            {
                innerListChanged = false;

                indexerForPrimaryKeys = new Dictionary <string, int>();

                for (int i = 0, count = this.List.Count; i < count; i++)
                {
                    BorrowORLoanInfo borrowInfo = this.List[i] as BorrowORLoanInfo;

                    indexerForPrimaryKeys.Add(string.Concat(borrowInfo.Id.ToString()), i);
                }
            }

            int index;

            if (indexerForPrimaryKeys.TryGetValue(string.Concat(id.ToString()), out index))
            {
                return(this.List[index] as BorrowORLoanInfo);
            }
            else
            {
                return(null);
            }
        }
        public bool Contains(BorrowORLoanInfo value)
        {
            if (IndexOf(value) > -1)
            {
                return(true);
            }

            return(false);
        }
        public int IndexOf(BorrowORLoanInfo value)
        {
            for (int i = 0, count = this.List.Count; i < count; i++)
            {
                if (value.Equals(this.List[i] as BorrowORLoanInfo))
                {
                    return(i);
                }
            }

            return(-1);
        }
Пример #5
0
 public BorrowORLoanInfo(BorrowORLoanInfo borrowInfo)
 {
     this.id = borrowInfo.Id;
     this.borrowORLoan = borrowInfo.BorrowORLoan;
     this.borrowORLoanType = borrowInfo.BorrowORLoanType;
     this.borrowORLoanAccountId = borrowInfo.BorrowORLoanAccountId;
     this.borrowedAccount = borrowInfo.BorrowedAccount;
     this.borrower = borrowInfo.Borrower;
     this.loanAccount = borrowInfo.LoanAccount;
     this.lender = borrowInfo.Lender;
     this.amount = borrowInfo.Amount;
     this.happenedDate = borrowInfo.HappenedDate;
     this.returnDate = borrowInfo.ReturnDate;
     this.status = borrowInfo.Status;
     this.content = borrowInfo.Content;
 }
Пример #6
0
 public BorrowORLoanInfo(BorrowORLoanInfo borrowInfo)
 {
     this.id                    = borrowInfo.Id;
     this.borrowORLoan          = borrowInfo.BorrowORLoan;
     this.borrowORLoanType      = borrowInfo.BorrowORLoanType;
     this.borrowORLoanAccountId = borrowInfo.BorrowORLoanAccountId;
     this.borrowedAccount       = borrowInfo.BorrowedAccount;
     this.borrower              = borrowInfo.Borrower;
     this.loanAccount           = borrowInfo.LoanAccount;
     this.lender                = borrowInfo.Lender;
     this.amount                = borrowInfo.Amount;
     this.happenedDate          = borrowInfo.HappenedDate;
     this.returnDate            = borrowInfo.ReturnDate;
     this.status                = borrowInfo.Status;
     this.content               = borrowInfo.Content;
 }
Пример #7
0
        public static BorrowORLoanInfo GetLoanById(int id)
        {
            BorrowORLoanInfo loanInfo = 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())
                {
                    loanInfo = new BorrowORLoanInfo(reader);
                }
            }
            return loanInfo;
        }
Пример #8
0
        public override bool Equals(object obj)
        {
            if (!base.Equals(obj))
            {
                return(false);
            }
            if (obj == null)
            {
                return(false);
            }
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }

            BorrowORLoanInfo borrowInfo = obj as BorrowORLoanInfo;

            return(this.id.Equals(borrowInfo.Id));
        }
Пример #9
0
        public static void AddTableRow(DataTable table, BorrowORLoanInfo borrowInfo)
        {
            System.Data.DataRow dr = table.NewRow();

            dr["Id"]                    = borrowInfo.id;
            dr["BorrowORLoan"]          = borrowInfo.borrowORLoan;
            dr["BorrowORLoanType"]      = borrowInfo.borrowORLoanType;
            dr["BorrowORLoanAccountId"] = borrowInfo.borrowORLoanAccountId;
            dr["BorrowedAccount"]       = borrowInfo.borrowedAccount;
            dr["Borrower"]              = borrowInfo.borrower;
            dr["LoanAccount"]           = borrowInfo.loanAccount;
            dr["Lender"]                = borrowInfo.lender;
            dr["Amount"]                = borrowInfo.amount;
            dr["HappenedDate"]          = borrowInfo.happenedDate;
            dr["ReturnDate"]            = borrowInfo.returnDate;
            dr["Status"]                = borrowInfo.status;
            dr["Content"]               = borrowInfo.content;
            table.Rows.Add(dr);
        }
Пример #10
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;
            }
        }
Пример #11
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;
            }
        }
        public void Remove(BorrowORLoanInfo value)
        {
            List.Remove(value);

            innerListChanged = true;
        }
        public int IndexOf(BorrowORLoanInfo value)
        {
            for (int i = 0, count = this.List.Count; i < count; i++)
            {
                if (value.Equals(this.List[i] as BorrowORLoanInfo))
                    return i;
            }

            return -1;
        }
        public void Insert(int index, BorrowORLoanInfo value)
        {
            List.Insert(index, value);

            innerListChanged = true;
        }
        public bool Contains(BorrowORLoanInfo value)
        {
            if (IndexOf(value) > -1)
                return true;

            return false;
        }
 public void CopyTo(BorrowORLoanInfo[] array, int index)
 {
     this.List.CopyTo(array, index);
 }
 public int Add(BorrowORLoanInfo value)
 {
     return this.List.Add(value);
 }
 public void AddRange(BorrowORLoanInfo[] value)
 {
     for (int i = 0; (i < value.Length); i++)
     {
         this.Add(value[i]);
     }
 }
Пример #19
0
 public static int InsertOrUpdatetoLoan(BorrowORLoanInfo info)
 {
     return LoanProxy.InsertOrUpdatetoLoan(info);
 }
Пример #20
0
        public static void AddTableRow(DataTable table, BorrowORLoanInfo borrowInfo)
        {
            System.Data.DataRow dr = table.NewRow();

            dr["Id"] = borrowInfo.id;
            dr["BorrowORLoan"] = borrowInfo.borrowORLoan;
            dr["BorrowORLoanType"] = borrowInfo.borrowORLoanType;
            dr["BorrowORLoanAccountId"] = borrowInfo.borrowORLoanAccountId;
            dr["BorrowedAccount"] = borrowInfo.borrowedAccount;
            dr["Borrower"] = borrowInfo.borrower;
            dr["LoanAccount"] = borrowInfo.loanAccount;
            dr["Lender"] = borrowInfo.lender;
            dr["Amount"] = borrowInfo.amount;
            dr["HappenedDate"] = borrowInfo.happenedDate;
            dr["ReturnDate"] = borrowInfo.returnDate;
            dr["Status"] = borrowInfo.status;
            dr["Content"] = borrowInfo.content;
            table.Rows.Add(dr);
        }
Пример #21
0
 public static int InsertOrUpdatetoBorrowed(BorrowORLoanInfo info)
 {
     return BorrowProxy.InsertOrUpdatetoBorrowed(info);
 }
 public int Add(BorrowORLoanInfo value)
 {
     return(this.List.Add(value));
 }
 /// <summary>
 /// Constructor using CcZlCzBillInfo array.
 /// </summary>
 /// <param name="value" />
 public BorrowORLoanCollection(BorrowORLoanInfo[] value)
 {
     this.AddRange(value);
 }
Пример #24
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);

        }
        public void Insert(int index, BorrowORLoanInfo value)
        {
            List.Insert(index, value);

            innerListChanged = true;
        }
Пример #26
0
        /// <summary>
        /// 新增或修改
        /// </summary>
        /// <param name="mySqlTransaction"></param>
        /// <param name="info"></param>
        /// <param name="iSuccess"></param>
        public static void InsertOrUpdatetoLoan(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 = 2;
            pars[2].Value = info.BorrowORLoanType;
            pars[3].Value = info.BorrowORLoanAccountId;
            pars[4].Value = info.BorrowedAccount;
            pars[5].Value = info.Borrower;
            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);
        }
        public void Remove(BorrowORLoanInfo value)
        {
            List.Remove(value);

            innerListChanged = true;
        }