コード例 #1
0
    /*****************************************************
    * - Function name : saveIncomeExpenseRecord
    * - Description : 保存收支记录
    * - Variables : IncomeExpense IE
    *****************************************************/
    public bool saveIncomeExpenseRecord(IncomeExpense IE)
    {
        string link = string.Format("server={0};User Id={1};password={2};Database={3}",
                                    MDB.getServer(), MDB.getUser(), MDB.getPassword(), MDB.getDatabase());
        MySqlConnection mycon = new MySqlConnection(link);

        mycon.Open();
        string sql = string.Format("insert into deal_detail_table values({0}, '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}', '{8}', '{9}')"
                                   , IE.getMoney()
                                   , IE.getDate()
                                   , IE.getReceive_name()
                                   , IE.getReceive_card()
                                   , IE.getAllocate_name()
                                   , IE.getAllocate_card()
                                   , IE.getDeal_way()
                                   , IE.getAssure_id()
                                   , IE.getDdt_note()
                                   , IE.getDeal_kind());
        MySqlCommand mycmd = new MySqlCommand(sql, mycon);

        if (mycmd.ExecuteNonQuery() > 0)
        {
            mycon.Close();
            return(true);
        }
        else
        {
            mycon.Close();
            return(false);
        }
    }
コード例 #2
0
        /// <summary>
        /// Get income and expense details for each service (see expenseGroups).
        /// </summary>
        /// <returns>Dictionary of name => IncomeExpense.</returns>
        public Dictionary <String, IncomeExpense> GetIncomesAndExpenses()
        {
            //LogMessage("Getting Income/Expense info.");
            Dictionary <String, IncomeExpense> incomeExpenses = new Dictionary <String, IncomeExpense>();

            foreach (IncomeExpenseGroup group in expenseGroups)
            {
                if (group.Levels > 0)
                {
                    for (int i = 1; i <= group.Levels; i++)
                    {
                        economyManager.GetIncomeAndExpenses(
                            group.Service, group.SubService, (ItemClass.Level)(i - 1),
                            out long income, out long expense);
                        incomeExpenses[$"{group.Name}_Lv{i}"] = new IncomeExpense {
                            Income  = income,
                            Expense = expense,
                            Level   = i,
                        };
                    }
                }
                else                   //This group doesn't have levels
                {
                    economyManager.GetIncomeAndExpenses(
                        group.Service, group.SubService,
                        ItemClass.Level.None,
                        out long income, out long expense);
                    incomeExpenses[group.Name] = new IncomeExpense {
                        Income  = income,
                        Expense = expense,
                        Level   = 0,
                    };
                }
            }

            //These aren't considered services
            incomeExpenses["LoanPayments"] = new IncomeExpense {
                Income  = 0,
                Expense = economyManager.GetLoanExpenses(),
                Level   = 0,
            };
            incomeExpenses["Policies"] = new IncomeExpense {
                Income  = 0,
                Expense = economyManager.GetPolicyExpenses(),
                Level   = 0,
            };

            return(incomeExpenses);
        }
コード例 #3
0
        private void btnSendRequest_Click(object sender, EventArgs e)
        {
            IncomeExpense ie = new IncomeExpense();

            ie = gridUtility.GetSelectedItem <IncomeExpense>();
            ie.IncomeExpenseId = Convert.ToInt32(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, gridView1.Columns["IncomeExpenseId"]));
            if (ie.ApproveStatusId == 1)
            {
                FlatMsgBox.Show("Đã có một yêu cầu khác gửi đi ở dòng này đang chờ xác nhận, không thể gửi thêm yêu cầu.");
                return;
            }
            if (ie == null)
            {
                return;
            }
            RequestSent rs = new RequestSent();

            rs.TableName = "IncomeExpense";
            rs.IdValue   = ie.IncomeExpenseId;
            rs.RequestTo = "quangphat";
            rs.RequestBy = UserManagement.UserSession.UserName;
            frmEditIncomExpense obj = new frmEditIncomExpense();

            obj.value = GetDetail;
            obj.ShowDialog();
            if (detail == null)
            {
                return;
            }
            rs.Detail = detail;

            try
            {
                ie.ApproveStatusId = 1;
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.RequestSentRepository.Add(rs);
                    uow.IncomeExpenseRepository.Update(ie);
                    uow.Commit();
                }
                FlatMsgBox.Show("Yêu cầu đã được gửi");
                detail = null;
            }
            catch
            {
                FlatMsgBox.Show("Không thể gửi yêu cầu");
            }
        }
コード例 #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            IncomeExpense ie = new IncomeExpense();

            CoverObjectUtility.GetAutoBindingData(this, ie);
            ie.PurposeSuggestion.PurposeName = (cbbPurpose.SelectedItem as PurposeSuggestion).PurposeName;
            ie.Department.DepartmentName     = (cbbDepartment.SelectedItem as Department).DepartmentName;
            ie.Staff.StaffName = (cbbStaff.SelectedItem as Staff).StaffName;
            ie.SetCreate();
            if (cbbPurpose.SelectedValue.ToString() == "1") //Ky quy
            {
                ie.RegisterValue = Convert.ToDecimal(txtMoneyOut.Text.Trim().Replace(",", ""));
                lastMoneyIn     += (decimal)ie.MoneyBack + (decimal)ie.RegisterValue; //MoneyIn tang
                ie.MoneyOut      = null;
            }
            else
            {
                lastMoneyIn = lastMoneyIn - (decimal)ie.MoneyOut + (decimal)ie.MoneyBack;
                ie.MoneyUse = (decimal)ie.MoneyOut - (decimal)ie.MoneyBack;
            }

            ie.MoneyIn         = lastMoneyIn;
            ie.ApproveStatusId = 2;
            ie.ApproveBy       = UserManagement.UserSession.UserName;
            ie.ApproveDate     = DateTime.Now;
            try
            {
                using (IUnitOfWork uow = new UnitOfWork())
                {
                    uow.IncomeExpenseRepository.Add(ie);
                    uow.Commit();
                }
            }
            catch { return; }
            if (add != null)
            {
                add(ie);
            }
            Close();
        }
コード例 #5
0
 private void Add(IncomeExpense sug)
 {
     gridUtility.AddNewRow(sug);
 }
コード例 #6
0
 /*****************************************************
 * - Function name : addIncomeExpense
 * - Description : 新建收支明细对象
 * - Variables : void
 *****************************************************/
 public void addIncomeExpense()
 {
     IE = new IncomeExpense();
 }