public bool Update(DTO_Payment payment)
        {
            connect();

            string sql = "UPDATE  capston1_customers.Payment SET  Amount=@Amount,GST =@GST, Received=@Received, Balance=@Balance, Description =@Description  WHERE  Matter_ID =  @Matter_ID";

            try
            {
                _cmd = new MySqlCommand(sql, _cnn);
                _cmd = new MySqlCommand(sql, _cnn);
                _cmd.Parameters.Add("@Matter_ID", MySqlDbType.VarChar, 30).Value = payment.Matter_ID;
                _cmd.Parameters.Add("@Amount", MySqlDbType.Decimal).Value        = payment.Amount;
                _cmd.Parameters.Add("@GST", MySqlDbType.Decimal).Value           = payment.GST;
                _cmd.Parameters.Add("@Received", MySqlDbType.Text).Value         = payment.Received;
                _cmd.Parameters.Add("@Balance", MySqlDbType.Text).Value          = payment.Balance;
                _cmd.Parameters.Add("@Description", MySqlDbType.Text).Value      = payment.Description;
                _cmd.ExecuteNonQuery();
                _cmd.Dispose();
                disconnect();
            }
            catch (Exception ex)
            {
                disconnect();
                return(false);

                throw ex;
            }
            return(true);
        }
        private void btnEdit_Click(object sender, RoutedEventArgs e)
        {
            DTO_Payment row        = (DTO_Payment)dgPayment.SelectedItem;
            DateTime    importDate = DateTime.ParseExact(row.Time, "dd/MM/yyyy HH:mm:ss", null);

            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeletePayment");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể chỉnh sửa phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }
            DTO_Payment dto = (DTO_Payment)dgPayment.SelectedItem;

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Sửa phiếu chi",
                Content               = new PopupPaymentEdit(dto),
                Width                 = 460,
                Height                = 420,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            loaddata();
        }
        public bool Insert(DTO_Payment payment)
        {
            connect();

            string sql = "INSERT INTO capston1_customers.Payment (Matter_ID, Receipt_No, Amount, GST, Received, Balance, Description) VALUES (@Matter_ID, @Receipt_No, @Amount, @GST, @Received, @Balance, @Description)";

            try
            {
                _cmd = new MySqlCommand(sql, _cnn);
                _cmd.Parameters.Add("@Matter_ID", MySqlDbType.VarChar, 30).Value = payment.Matter_ID;
                _cmd.Parameters.Add("@Receipt_No", MySqlDbType.Text).Value       = payment.Receipt_No;
                _cmd.Parameters.Add("@Amount", MySqlDbType.Decimal).Value        = payment.Amount;
                _cmd.Parameters.Add("@GST", MySqlDbType.Decimal).Value           = payment.GST;
                _cmd.Parameters.Add("@Received", MySqlDbType.Text).Value         = payment.Received;
                _cmd.Parameters.Add("@Balance", MySqlDbType.Text).Value          = payment.Balance;
                _cmd.Parameters.Add("@Description", MySqlDbType.Text).Value      = payment.Description;
                _cmd.ExecuteNonQuery();
                _cmd.Dispose();
                disconnect();
            }
            catch (Exception ex)
            {
                disconnect();
                return(false);

                throw ex;
            }
            return(true);
        }
Exemple #4
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbMoneyValidation.Text = "";
            if (tbMoney.Text == "")
            {
                tbMoneyValidation.Text = "Số tiền không được để trống.";
                return;
            }
            DTO_Payment dto = new DTO_Payment();

            dto.PaymentID   = bus.createID();
            dto.EmployeeID  = mainWindow.GetCurrentEmpID();
            dto.Time        = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss tt");
            dto.TotalAmount = float.Parse(tbMoney.Text);
            dto.Description = tbDescription.Text;
            if (bus.createNewPayment(dto) > 0)
            {
                MessageBox.Show($"Đã thêm phiếu chi {dto.PaymentID}.");
                Window.GetWindow(this).Close();
            }
            else
            {
                MessageBox.Show("Đã có lỗi trong quá trình thêm phiếu chi.");
            }
        }
Exemple #5
0
        private void btSave_Click(object sender, RoutedEventArgs e)
        {
            tbMoneyValidation.Text = "";
            if (tbMoney.Text == "")
            {
                tbMoneyValidation.Text = "Số tiền không được để trống.";
                return;
            }
            DTO_Payment Payment = new DTO_Payment();

            Payment.PaymentID   = ID;
            Payment.EmployeeID  = bus.getEmployeeID(tbEmployeeName.Text);
            Payment.TotalAmount = float.Parse(tbMoney.Text);
            Payment.Time        = tbTime.Text;
            Payment.Description = tbDescription.Text;
            if (bus.editPayment(Payment) > 0)
            {
                MessageBox.Show($"Đã sửa phiếu chi {Payment.PaymentID}.");
                Window.GetWindow(this).Close();
            }
            else
            {
                MessageBox.Show("Đã có lỗi trong quá trình sửa phiếu chi.");
            }
        }
Exemple #6
0
        public PopupPaymentEdit(DTO_Payment payment)
        {
            InitializeComponent();
            ID = payment.PaymentID;
            DataTable tb = bus.findPaymentbyID(payment.PaymentID);

            foreach (DataRow row in tb.Rows)
            {
                tbMoney.Text        = row["TotalAmount"].ToString();
                tbTime.Text         = row["Time"].ToString();
                tbEmployeeName.Text = row["EmployeeName"].ToString();
                tbDescription.Text  = row["Description"].ToString();
            }
        }
        public PopupPaymentDetail(DTO_Payment dto)
        {
            InitializeComponent();
            bus = new BUS_Payment();
            DataTable tb = bus.findPaymentbyID(dto.PaymentID);

            foreach (DataRow row in tb.Rows)
            {
                tbAmount.Text       = row["TotalAmount"].ToString();
                tbTime.Text         = row["Time"].ToString();
                tbPaymentID.Text    = row["PaymentID"].ToString();
                tbEmployeeName.Text = row["EmployeeName"].ToString();
                tbDescription.Text  = row["Description"].ToString();
            }
        }
        public async Task AddPayment(DTO_Payment token)
        {
            try
            {
                var response = await client.PostAsJsonAsync(string.Format(@"{0}{1}", URL, "AddPayment"),
                                                            token);

                response.EnsureSuccessStatusCode();
                Payment = await response.Content.ReadAsAsync <DTO_Payment>();
            }
            catch (Exception e)
            {
                Console.Write(e.StackTrace);
            }
        }
Exemple #9
0
        public int createNewPayment(DTO_Payment Payment)
        {
            int    rs  = 0;
            string sql = $"Insert into PaymentVoucher values ('" + Payment.PaymentID + "'," + Payment.TotalAmount + ",'" + Payment.Description + "','" + Payment.EmployeeID + "','" + Payment.Time + "')";

            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, getConnection());
                command.Connection.Open();
                rs = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            return(rs);
        }
Exemple #10
0
        async private void SubmitScopeEntry_Click(object sender, RoutedEventArgs e)
        {
            int.Parse(s1.ClaimsList[claimIDComboBox.SelectedIndex].ClaimID.ToString());
            if (claimIDComboBox.SelectedIndex > -1)
            {
                if (paymentTypeComboBox.SelectedIndex > -1)
                {
                    if (paymentDateDatePicker.SelectedDate != null && paymentDateDatePicker.SelectedDate >= DateTime.Today)
                    {
                        DTO_Payment p = new DTO_Payment();

                        p.Amount               = double.Parse(amountTextBox.Text);
                        p.PaymentDate          = paymentDateDatePicker.SelectedDate.Value;
                        p.PaymentDescriptionID = ((DTO_LU_PaymentDescription)paymentTypeComboBox.SelectedValue).PaymentDescriptionID;
                        p.ClaimID              = ((DTO_Claim)claimIDComboBox.SelectedValue).ClaimID;
                        await s1.AddPayment(p);



                        if (s1.Payment.Message == null)
                        {
                            MessageBox.Show(s1.Payment.PaymentID.ToString());
                        }
                        else
                        {
                            MessageBox.Show(s1.Payment.Message);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Select a date");
                    }
                }
                else
                {
                    MessageBox.Show("Select a Payment Description");
                }
            }
            else
            {
                MessageBox.Show("Pick a Claim Number");
            }
        }
Exemple #11
0
        public int editPayment(DTO_Payment Payment)
        {
            int rs = 0;

            Console.WriteLine(Payment.PaymentID);
            string sql = $"Update PaymentVoucher set PaymentID='" + Payment.PaymentID + "', EmployeeID='" + Payment.EmployeeID + "', TotalAmount=" + Payment.TotalAmount + ",Time='" + Payment.Time + "',Description='" + Payment.Description + "' Where PaymentID='" + Payment.PaymentID + "'";

            try
            {
                SQLiteCommand command = new SQLiteCommand(sql, getConnection());
                command.Connection.Open();
                rs = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
            }
            return(rs);
        }
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            DTO_Payment row        = (DTO_Payment)dgPayment.SelectedItem;
            DateTime    importDate = DateTime.ParseExact(row.Time, "dd/MM/yyyy HH:mm:ss tt", null);

            BUS_Parameter busParameter = new BUS_Parameter();
            int           limitDay     = busParameter.GetValue("DayDeletePayment");

            if ((DateTime.Now - importDate) > TimeSpan.FromDays(limitDay))
            {
                MessageBox.Show($"Không thể xóa phiếu đã được tạo cách đây hơn {limitDay} ngày.");
                return;
            }

            DTO_Payment dto = (DTO_Payment)dgPayment.SelectedItem;

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Xóa phiếu chi",
                Content               = new PopupDeleteConfirm("Dữ liệu về " + dto.PaymentID + " sẽ bị xóa vĩnh viễn.\nBạn chắc chắn muốn xóa?", dto.PaymentID, 2),
                Width                 = 420,
                Height                = 210,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
            numRow--;
            setNumPage();
            if (maxNumpage < int.Parse(tbNumPage.Text))
            {
                tbNumPage.Text = (int.Parse(tbNumPage.Text) - 1).ToString();
            }
            loaddata();
        }
        private void btnWatch_Click(object sender, RoutedEventArgs e)
        {
            DTO_Payment dto = (DTO_Payment)dgPayment.SelectedItem;

            System.Windows.Media.Effects.BlurEffect objBlur = new System.Windows.Media.Effects.BlurEffect();
            ((MainWindow)App.Current.MainWindow).Opacity = 0.5;
            ((MainWindow)App.Current.MainWindow).Effect  = objBlur;
            Window window = new Window
            {
                ResizeMode            = ResizeMode.NoResize,
                WindowStyle           = WindowStyle.None,
                Title                 = "Chi tiết phiếu chi",
                Content               = new PopupPaymentDetail(dto),
                Height                = 440,
                Width                 = 460,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window.ShowDialog();

            ((MainWindow)App.Current.MainWindow).Opacity = 1;
            ((MainWindow)App.Current.MainWindow).Effect  = null;
        }
Exemple #14
0
 public int createNewPayment(DTO_Payment Payment)
 {
     return(dalPayment.createNewPayment(Payment));
 }
Exemple #15
0
 public int editPayment(DTO_Payment Payment)
 {
     return(dalPayment.editPayment(Payment));
 }
 public bool Update(DTO_Payment payment)
 {
     return(DAO_payment.Update(payment));
 }
 public bool Insert(DTO_Payment payment)
 {
     return(DAO_payment.Insert(payment));
 }