private void btnPrint_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            Form fx = new frmReportViewer1(ReportHelper1.LoadPurchaseOrderForm(c1TextBox1.Text));

            fx.WindowState = FormWindowState.Maximized;
            fx.ShowDialog();
            Cursor = Cursors.Default;
        }
Exemplo n.º 2
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            Form fx = new frmReportViewer1(ReportHelper1.LoadPurchaseInvoiceList((DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)));

            fx.WindowState = FormWindowState.Maximized;
            fx.ShowDialog();
            Cursor = Cursors.Default;
        }
Exemplo n.º 3
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            Form fx = new frmReportViewer1(ReportHelper1.LoadInventoryStatus());

            fx.WindowState = FormWindowState.Maximized;
            fx.ShowDialog();
            Cursor = Cursors.Default;
        }
Exemplo n.º 4
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.AppStarting;
            Form fx = new frmReportViewer1(ReportHelper1.LoadPurchaseOrderList((DateTime)dtpBegin.Value, ((DateTime)dtpEnd.Value).AddDays(1)));

            fx.WindowState = FormWindowState.Maximized;
            fx.ShowDialog();
            Cursor = Cursors.Default;

            /*
             * old print using c1report
             * **************************
             * Cursor = Cursors.AppStarting;
             *
             * // hide unecessary column
             * this._grid.Caption = "";
             *
             * // page setting
             * C1.Win.C1TrueDBGrid.Style headerstyle = new C1.Win.C1TrueDBGrid.Style();
             * headerstyle.Font = new Font("Tahome", 18, FontStyle.Bold);
             * headerstyle.HorizontalAlignment = C1.Win.C1TrueDBGrid.AlignHorzEnum.Center;
             * this._grid.PrintInfo.PageHeader = this.Text;
             * this._grid.PrintInfo.PageHeaderStyle = headerstyle;
             * this._grid.PrintInfo.PageSettings.Landscape = true;
             * this._grid.PrintInfo.PageSettings.Margins.Top = 30;
             * this._grid.PrintInfo.PageSettings.Margins.Left = 30;
             * this._grid.PrintInfo.PageSettings.Margins.Bottom = 30;
             * this._grid.PrintInfo.PageSettings.Margins.Right = 30;
             * this._grid.PreviewInfo.Size = new System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
             *
             * // Column headers will be on every page.
             * this._grid.PrintInfo.RepeatColumnHeaders = true;
             *
             * // Display page numbers (centered).
             * this._grid.PrintInfo.PageFooter = @"Page: \p\t";
             * this._grid.PrintInfo.PageFooter += Reports.ReportHelper1.GenerateFooter();
             *
             * // Invoke print preview.
             * this._grid.PrintInfo.UseGridColors = false;
             * this._grid.PrintInfo.PrintPreview();
             *
             * // unhide unecessary column
             * this._grid.Caption = this.Text;
             *
             * Cursor = Cursors.Default;
             * */
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Validate all required field(s)
            if (!ValidateUserInput())
            {
                return;
            }

            // if you get here, it means that all user input has been validated
            Cursor = Cursors.AppStarting;

            try
            {
                // End editing
                BindingContext[dsCore1, "Orders"].EndCurrentEdit();
                BindingContext[dsCore1, "OrderDetails"].EndCurrentEdit();

                // There are changes that need to be made, so attempt to update the datasource by
                // calling the update method and passing the dataset and any parameters.
                if (txMode == DataEntryModes.Add)
                {
                    // copy master record dari main dataset
                    // harus dilakukan krena main dataset sebelumnya sudah
                    // AcceptChanges padahal belum diupdate ke database
                    dsChanges = new dsCore();
                    dsChanges.EnforceConstraints = false;
                    dsChanges.Orders.Rows.Add(((DataRowView)this.BindingContext[dsCore1, "Orders"].Current).Row.ItemArray);

                    // copy juga detail record dari main dataset
                    for (int i = 0; i < dsCore1.OrderDetails.Rows.Count; i++)
                    {
                        dsChanges.OrderDetails.Rows.Add(dsCore1.OrderDetails.Rows[i].ItemArray);
                    }

                    // persist changes to database
                    daOrders1.Update(dsChanges.Orders);
                    daOrderDetails1.Update(dsChanges.OrderDetails);

                    // only generate invoice
                    GenerateInvoice(dsChanges);

                    // generate payment record for cash payment
                    if (radioButton1.Checked || Convert.ToDouble(c1NumericEdit1.Value) > 0)
                    {
                        GeneratePayment(dsChanges);
                    }

                    // inform user, successful
                    DialogResult dr = RibbonMessageBox.Show("Data SUCCESFULLY saved to database\n" +
                                                            (InvoiceID < 0 ? "" : "New Invoice Voucher [" + InvoiceNum + "] created automatically\n") +
                                                            (PaymentID < 0 ? "" : "New Payment Voucher [" + PaymentNum + "] created automatically\n") +
                                                            "Do you want to print this document?\n",
                                                            Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    // ask user for voucher print
                    if (dr == DialogResult.Yes)
                    {
                        Cursor = Cursors.AppStarting;
                        Form fx = new frmReportViewer1(ReportHelper1.LoadPurchaseOrderForm(c1TextBox1.Text));
                        fx.WindowState = FormWindowState.Maximized;
                        fx.ShowDialog();
                        Cursor = Cursors.Default;
                    }
                }
                else
                {
                    // persist changes to database
                    daOrders1.Update(dsCore1.Orders);
                    daOrderDetails1.Update(dsCore1.OrderDetails);

                    // inform user for successful update
                    RibbonMessageBox.Show("Changes SUCCESFULLY saved to database",
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                // success, close form
                btnClose.PerformClick();
            }
            catch (SqlException ex)
            {
                // textfile logging
                Logger.ErrorRoutine(ex);

                // screen logging
                if (ex.Number != 2601)
                {
                    RibbonMessageBox.Show("ERROR Saving Data: \n" + ex.Message,
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    RibbonMessageBox.Show("ERROR Saving Data:\n" +
                                          "Document number [" + c1TextBox1.Text + "]already existed in database\n" +
                                          "Please change this document number and try saving again.",
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                // textfile logging
                Logger.ErrorRoutine(ex);

                // screen logging
                RibbonMessageBox.Show("ERROR Saving Data: \n" + ex.Message,
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            Cursor = Cursors.Default;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            // Validate all required field(s)
            if (!ValidateUserInput())
            {
                return;
            }

            // if you get here, it means that all user input has been validated
            Cursor = Cursors.AppStarting;

            try
            {
                // End editing
                BindingContext[dsCore1, "Orders"].EndCurrentEdit();
                BindingContext[dsCore1, "OrderDetails"].EndCurrentEdit();


                // Validaton Check order detail item -> by K
                if (dsCore1.OrderDetails.Rows.Count == 0)
                {
                    RibbonMessageBox.Show("No item inventory in this order\n" +
                                          "Please input item at least one item\n",
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                // End Validation -> by K

                // There are changes that need to be made, so attempt to update the datasource by
                // calling the update method and passing the dataset and any parameters.
                if (txMode == DataEntryModes.Add)
                {
                    // copy master record dari main dataset
                    // harus dilakukan krena main dataset sebelumnya sudah
                    // AcceptChanges padahal belum diupdate ke database
                    dsChanges = new dsCore();
                    dsChanges.EnforceConstraints = false;

                    // Possible NULL value dataRowView .:By K:.
                    var dataRowView = (DataRowView)BindingContext[dsCore1, "Orders"].Current;
                    if (dataRowView != null)
                    {
                        dsChanges.Orders.Rows.Add(dataRowView.Row.ItemArray);
                    }


                    // copy juga detail record dari main dataset
                    for (var i = 0; i < dsCore1.OrderDetails.Rows.Count; i++)
                    {
                        dsChanges.OrderDetails.Rows.Add(dsCore1.OrderDetails.Rows[i].ItemArray);
                    }

                    // persist changes to database
                    daOrders1.Update(dsChanges.Orders);
                    daOrderDetails1.Update(dsChanges.OrderDetails);

                    // inform user, successful
                    DialogResult dr = RibbonMessageBox.Show("Data SUCCESFULLY saved to database\n" +
                                                            "Do you want to print this document?\n",
                                                            Application.ProductName, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    // ask user for voucher print
                    if (dr == DialogResult.Yes)
                    {
                        Cursor = Cursors.AppStarting;
                        Form fx = new frmReportViewer1(ReportHelper1.LoadSalesQuotationForm(c1TextBox1.Text));
                        fx.WindowState = FormWindowState.Maximized;
                        fx.ShowDialog();
                        Cursor = Cursors.Default;
                    }
                }
                else
                {
                    // persist changes to database
                    daOrders1.Update(dsCore1.Orders);
                    daOrderDetails1.Update(dsCore1.OrderDetails);

                    // inform user for successful update
                    RibbonMessageBox.Show("Changes SUCCESFULLY saved to database",
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                // success, close form
                btnClose.PerformClick();
            }
            catch (SqlException ex)
            {
                // textfile logging
                Logger.ErrorRoutine(ex);

                // screen logging
                if (ex.Number != 2601)
                {
                    RibbonMessageBox.Show("ERROR Saving Data: \n" + ex.Message,
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
                else
                {
                    RibbonMessageBox.Show("ERROR Saving Data:\n" +
                                          "Document number [" + c1TextBox1.Text + "]already existed in database\n" +
                                          "Please change this document number and try saving again.",
                                          Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                // textfile logging
                Logger.ErrorRoutine(ex);

                // screen logging
                RibbonMessageBox.Show("ERROR Saving Data: \n" + ex.Message,
                                      Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            Cursor = Cursors.Default;
        }