Exemple #1
0
        public bool Add_and_Edit_HistoryInterest(historyInterestRate historyInterest, int action_status, user user)
        {
            bool check = false;

            try
            {
                historyInterest.CreatedBy      = user.id;
                historyInterest.UpdatedBy      = user.id;
                historyInterest.InterestRateId = 1;
                historyInterest.Status         = true;
                historyInterest.CreatedAt      = DateTime.Now;
                historyInterest.UpdatedAt      = DateTime.Now;
                changeStatusHistoryInterest();
                _db.historyInterestRates.Add(historyInterest);
                _db.SaveChanges();
                check = true;
            }
            catch (Exception)
            {
                return(check);
            }
            return(check);
        }
        private void btn_add_interest_Click(object sender, EventArgs e)
        {
            try
            {
                historyInterestRate historyInterest = new historyInterestRate();
                if (CheckValidate() == true)
                {
                    if (Util.Show_Message_YesNo(Message.msg_notification, "Chắc chắn muốn thêm ?"))
                    {
                        {
                            historyInterest.Percents  = Double.Parse(txt_percent.Text.Trim().Replace(".", ","));
                            historyInterest.Note      = txt_ghi_chu.Text.Trim();
                            historyInterest.CreatedAt = DateTime.Now;
                            historyInterest.UpdatedAt = DateTime.Now;
                            historyInterest.Status    = true;
                            historyInterest.StartDate = DateTime.Parse(date_start.Text.ToString().Trim());

                            bool check = DAL_QLLaiSuat.Add_and_Edit_HistoryInterest(historyInterest, Variable.action_status.is_add, _user);
                            if (check == true)
                            {
                                Util.Show_Message_Notification(Message.msg_notification, Message.msg_success_add_data);
                                Load_Data();
                            }
                            else
                            {
                                Util.Show_Message_Error(Message.msg_error, Message.msg_error_add_data);
                            }
                            restartFormAddInterest();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }