Пример #1
0
        public PaymentForm(int id)
        {
            InitializeComponent();

            //User label
            userid = id;
            user = new Users();
            setup(userid.ToString(), "FAFOS Payment Form");

            payment = new Payment();
            txtInvoice.DataSource = payment.getNotPaid(userid);
            txtInvoice.DisplayMember = "id";
            txtInvoice.ValueMember = "id";

            // Enable the owner draw on the ComboBox.
            this.txtInvoice.DrawMode = DrawMode.OwnerDrawFixed;
            // Handle the DrawItem event to draw the items.
            this.txtInvoice.DrawItem += delegate(object cmb, DrawItemEventArgs args)
            {
                // Draw the default background
                args.DrawBackground();

                // The ComboBox is bound to a DataTable,
                // so the items are DataRowView objects.
                DataRowView drv = (DataRowView)this.txtInvoice.Items[args.Index];

                // Retrieve the value of each column.
                string paymentid = drv["id"].ToString();
                string date = drv["Date Issued"].ToString();
                string due = drv["Date Due"].ToString();
                string total = drv["Total"].ToString();
                // Get the bounds for the first column
                Rectangle r1 = args.Bounds;
                r1.Width =400/ 4;

                // Draw the text on the first column
                using (SolidBrush sb = new SolidBrush(args.ForeColor))
                {
                    args.Graphics.DrawString(paymentid,  new Font(args.Font.FontFamily, args.Font.Size, FontStyle.Bold), sb, r1);
                }

                Rectangle r2 = drawColumns(args, r1, date, 100);
               Rectangle r3 = drawColumns(args, r2, due,200);
               drawColumns(args, r3, total, 300);

               txtInvoice.DropDownWidth = 450;

            };
        }
Пример #2
0
        public void Notifications()
        {
            DataTable dt2 = new ClientContract().getServices(userid.ToString());
            serviceNotification.Text = "";

            for (int i = 0; i < dt2.Rows.Count; i++)
            {

                if (Convert.ToDateTime(dt2.Rows[i][2]) == DateTime.Today)
                {
                    String service = dt2.Rows[i][0].ToString();
                    serviceNotification.Text += "\n" + service + " needs to be completed by today ";
                    serviceNotification.Text += "location - " + dt2.Rows[i][5].ToString() + "\n";
                }

            }
            if (serviceNotification.Text == "")
             serviceNotification.Text = "";

               DataTable dt = new Payment().getNotPaid(userid);
               paymentNotification.Text = "";
               for (int i = 2; i < dt.Rows.Count; i++)
               {
               if (Convert.ToDateTime(dt.Rows[i][2]) == DateTime.Today)
               {
                   String name = new Client().getName(new ClientContract().getClient(new SalesOrder().getSAddress(new Invoice().getSalesOrderID(dt.Rows[i][0].ToString()).ToString())));
                   paymentNotification.Text += "\n"+name+" has an outstanding balance of ";

                   DataTable payments = new Payment().getAmount(dt.Rows[i][0].ToString());
                   double total=0;
                   for (int j = 0; j < payments.Rows.Count; j++)
                   {
                       total += Convert.ToDouble(payments.Rows[j][2]);

                   }
                   paymentNotification.Text +=  "$" +String.Format("{0:0.00}",Math.Round(Convert.ToDouble(dt.Rows[i][3].ToString()) - total,2))
                       + " on invoice #" + dt.Rows[i][0].ToString()+"\n";
               }
               }
               if (paymentNotification.Text == "")
               paymentNotification.Text = "None";
        }
Пример #3
0
        private void Submit_btn_Click(object sender, EventArgs e)
        {
            if (txtBalance.DecimalValue == 0)
            {
                new Invoice().update(txtInvoice.SelectedValue.ToString());
                MessageBox.Show("Invoice has been fully paid.");
                this.Close();
            }
            //Add Payment
            //if (txtAmount.Text != "0" && txtAmount.Text != "" && txtAmount.Text != "$0.00")

            if(txtAmount.DecimalValue != 0 && txtAmount.DecimalValue <= txtBalance.DecimalValue && txtType.Text != "" && txtAmount.DecimalValue > 0)
            {
                Payment pay = new Payment();
                int payId;

                payId = pay.set("'" + DateTime.Today.Date.ToString() + "','" + txtType.Text + "'," +
                            txtAmount.Text + ",'" + txtRemarks.Text + "'," +
                            new ClientContract().getClient(new SalesOrder().getSAddress(new Invoice().getSalesOrderID(txtInvoice.SelectedValue.ToString()).ToString())));

                pay.setIP(txtInvoice.SelectedValue.ToString() + "," + payId);

                //Check if all of invoice is paid off

                if (txtAmount.DecimalValue == txtBalance.DecimalValue )
                {
                    new Invoice().update(txtInvoice.SelectedValue.ToString());
                    MessageBox.Show("Invoice has been fully paid.");
                }

                else
                    MessageBox.Show("Payment has been processed.");
                this.Close();
            }
            else if (txtAmount.DecimalValue <= 0)
            {
                MessageBox.Show("The payment amount must be greater than 0.");
            }
            else if (txtType.Text == "")
            {
                MessageBox.Show("A payment type was not selected");
            }
            else
            {
                MessageBox.Show("The payment was greater than the remaining Balance");
            }
        }