Example #1
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     if (dgvStock.Rows.Count > 0)
     {
         ReportInfo info = new ReportInfo();
         info.Report = Report.Stock;
         info.Options = GetFilter(true);
         ReceiptViewer print = new ReceiptViewer(info);
         print.ShowDialog();
     }
     else if (dgvStock.Rows.Count <= 0)
     {
         MessageBox.Show("No Record Found" + Environment.NewLine + "Please make sure that Stock is not empty", "Stock Print Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Example #2
0
        private void btnCustomerListPrint_Click(object sender, EventArgs e)
        {
            if (Status_Customer == 0 && dgvData.Rows.Count > 0)
            {
                string options = "0,0";
                if (chkOnlyActive.Checked)
                    options = "1,0";
                ReportInfo info = new ReportInfo() { Options = options, Report = Report.CompanyCustomerList };
                ReceiptViewer print = new ReceiptViewer(info);
                print.ShowDialog();
            }
            else
            {
                if (Status_Customer != 0)
                {
                    Common.ShowInvlaidCodeMessage(cbSearchByCode, Modules.Customer);
                }
                else if (dgvData.Rows.Count == 0)
                {
                    MessageBox.Show("Error ! No Record Found" + Environment.NewLine + "Sorry No Customer Record Found for Print", "Customer Code", MessageBoxButtons.OK, MessageBoxIcon.Error);

                }
            }
        }
Example #3
0
        void MakePayment()
        {
            decimal amount = 0;
            string companyId = string.IsNullOrEmpty(cbCustomersSuppliers.ValueMember) ? string.Empty : cbCustomersSuppliers.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCustomersSuppliers.SelectedItem)).Row[cbCustomersSuppliers.ValueMember]);//cbCustomers.SelectedValue.ToString();
            if (!string.IsNullOrEmpty(companyId) && companyId != "0")
            {
                if (decimal.TryParse(txtAmount.Text, out amount) & amount != 0)
                {

                    if (Common.IsMatch(txtAmount.Text))
                    {
                        if (!string.IsNullOrEmpty(txtComments.Text))
                        {
                            string strAmount = txtAmount.Text;
                            if (rbDebit.Checked)
                                strAmount = "-" + strAmount;
                            long TransactioId = 0;
                            if (IsCustomer)
                                TransactioId = customer.MakePayment(companyId, Common.FormateDateForDB(dtpDate.Value),strAmount, txtComments.Text);
                            else
                                TransactioId = company.MakePayment(companyId, Common.FormateDateForDB(dtpDate.Value), strAmount, txtComments.Text);
                            if (TransactioId > 0)
                            {
                                //ResetPayment();
                                string msg = "Payment made successfully." + Environment.NewLine +
                                    "Do you want to print?";
                                if (MessageBox.Show(msg, "Payment Successfully Completed", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                    == System.Windows.Forms.DialogResult.Yes)
                                {
                                    ReportInfo info = new ReportInfo() { Id = TransactioId, Report = Report.Payment, Options = "1" };
                                    ReceiptViewer print = new ReceiptViewer(info);
                                    print.ShowDialog();
                                }
                            }
                            else
                            {
                                //MessageBox.Show("Operation could not be completed.");
                                MessageBox.Show("Operation could not be completed", "Operation Failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }

                        else
                        {
                            MessageBox.Show("Comments are Mendatory", "Comments ", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            txtComments.Focus();

                        }
                    }
                    else
                    {
                        //MessageBox.Show("Comments are Mendatory.");
                        MessageBox.Show("Please Enter the Correct formate for balance" + Environment.NewLine +
                     "It only allow maxmuim two digit decimal like 99.99", "Format Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                }
                else
                {
                    //MessageBox.Show("InValid Amount.Please specify a valid amount.");
                    MessageBox.Show("InValid Amount.Please specify a valid amount.", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtAmount.Text = "0.00";
                    txtAmount.Focus();
                }
            }
            else
            {
                if (IsCustomer)
                    MessageBox.Show("Please select a Customer to make a payment.", "Select Customer", MessageBoxButtons.OK, MessageBoxIcon.Error);
                else
                    MessageBox.Show("Please select a Supplier to make a payment.", "Select Supplier", MessageBoxButtons.OK, MessageBoxIcon.Error);
                cbCustomersSuppliers.Focus();
            }
        }
Example #4
0
 private void printToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (dgvReceipts.SelectedRows.Count > 0)
     {
         long Id = Convert.ToInt64(dgvReceipts.SelectedRows[0].Cells["Id"].Value);
         if (Id > 0)
         {
             ReportInfo info = new ReportInfo();
             info.Id = Id;
             info.Report = Report.Receipt;
             ReceiptViewer print = new ReceiptViewer(info);
             print.ShowDialog();
         }
     }
 }
Example #5
0
        private void printToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (dgvTransactions.SelectedRows.Count > 0)
            {
                long Id = Convert.ToInt64(dgvTransactions.SelectedRows[0].Cells["TransactionId"].Value);
                if (Id > 0)
                {

                    ReportInfo info = new ReportInfo() { Id = Id, Report = Report.Payment, Options = "1" };
                    ReceiptViewer print = new ReceiptViewer(info);
                    print.ShowDialog();

                }
            }
        }
Example #6
0
        void Save()
        {
            if (dgvItems.Rows.Count > 0)
            {
                string CompanyId = string.IsNullOrEmpty(cbCompanies.ValueMember) ? string.Empty : cbCompanies.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCompanies.SelectedItem)).Row[cbCompanies.ValueMember]);//Convert.ToString(cbCompanies.SelectedValue);
                string GrandTotal = lblGrandTotal.Text;
                string Discount = txtExpenses.Text;
                string Payment = txtPayment.Text;
                string Arrears = lblArrears.Text;

                DataTable dt = item.SelectEmptyInvoiceDetailTable();
                foreach (DataGridViewRow row in dgvItems.Rows)
                {
                    DataRow dr = dt.NewRow();
                    dr["Id"] = row.Cells["colSerial"].Value;
                    dr["ItemId"] = row.Cells["colItemId"].Value;
                    dr["PurchasePrice"] = row.Cells["colPrice"].Value;
                    dr["Quantity"] = row.Cells["colQuantity"].Value;
                    dr["Total"] = row.Cells["colTotal"].Value;
                    dr["Discount"] = row.Cells["colDiscount"].Value;
                    dr["GrandTotal"] = row.Cells["colGrandTotal"].Value;
                    dt.Rows.Add(dr);
                }

                ReportInfo reportInfo = new ReportInfo();
                long Id = order.SaveOrder(CompanyId, GrandTotal, Discount, Payment, Arrears, txtComments.Text, dtDeliveryDate.Value, dt, false);
                MessageBox.Show("Order Saved Sucessfully.....","Save Successfully"
                                ,MessageBoxButtons.OK,MessageBoxIcon.Information);
                reportInfo.Id = Id;
                reportInfo.Report = Report.Order;
                ReceiptViewer receipt = new ReceiptViewer(reportInfo);
                receipt.ShowDialog();
                ResetInvoice();
            }
            else
            {
                MessageBox.Show("Error !No Item for Invoice...","Error"
                                ,MessageBoxButtons.OK,MessageBoxIcon.Error);
            }
        }
Example #7
0
 //ITEM LIST PRINT BUTTON
 private void btnItemListPrint_Click(object sender, EventArgs e)
 {
     ReportInfo info = null;
     if (rbAll.Checked)
         info = new ReportInfo() { Report = Report.ItemList, Options = chkitemView.Checked ? "1" : "0" };
     else
     {
         string CompanyId = cbItemSearch.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbItemSearch.SelectedItem)).Row[cbItemSearch.ValueMember]);
         info = new ReportInfo() { Report = Report.ItemListBySupplier, Options = CompanyId };
     }
     ReceiptViewer print = new ReceiptViewer(info);
     print.ShowDialog();
 }
Example #8
0
        void Save(string CustomerId)
        {
            if (dgvItems.Rows.Count > 0)
            {
                if (string.IsNullOrEmpty(CustomerId) || Convert.ToInt32(CustomerId) < 1)
                    CustomerId = string.IsNullOrEmpty(cbCustomer.ValueMember) ? string.Empty : cbCustomer.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCustomer.SelectedItem)).Row[cbCustomer.ValueMember]);//Convert.ToString(cbCustomer.SelectedValue);
                string GrandTotal = lblGrandTotal.Text;
                string Discount = txtTotalDiscount.Text;
                string NetTotal = txtNetTotal.Text;
                string Payment = txtPayment.Text;
                decimal Arearrs = 0;
                decimal.TryParse(lblArearrs.Text, out Arearrs);
                if (chkCash.Checked || cbCustomer.Text.ToLower() == "cash")
                {
                    if (Arearrs > 0)
                    {
                        MessageBox.Show("Cash sale should have full payment.", "Cash Sale", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (Arearrs < 0)
                    {
                        MessageBox.Show("Cash Customer can not pay more than Receipt Total.", "Cash Sale", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                DataTable dt = item.SelectEmptyReceiptDetailTable();
                foreach (DataGridViewRow row in dgvItems.Rows)
                {
                    decimal sprice = 0;
                    decimal qty = 0;
                    decimal total = 0;
                    decimal disc = 0;
                    decimal ftotal = 0;
                    decimal discPerItem = 0;

                    decimal.TryParse(Convert.ToString(row.Cells["colSalePrice"].Value), out sprice);
                    decimal.TryParse(Convert.ToString(row.Cells["colQuantity"].Value), out qty);
                    decimal.TryParse(Convert.ToString(row.Cells["colTotal"].Value), out total);
                    decimal.TryParse(Convert.ToString(row.Cells["colDiscount"].Value), out disc);
                    decimal.TryParse(Convert.ToString(row.Cells["colFinalTotal"].Value), out ftotal);
                    decimal.TryParse(Convert.ToString(row.Cells["colDiscountPerItem"].Value), out discPerItem);

                    DataRow dr = dt.NewRow();
                    dr["Id"] = row.Cells["colSerial"].Value;
                    dr["ItemId"] = row.Cells["colItemId"].Value;
                    dr["SalePrice"] = sprice;
                    dr["Quantity"] = qty;
                    dr["GrandTotal"] = total;
                    dr["Discount"] = disc;
                    dr["Total"] = ftotal;
                    dr["ItemDiscount"] = discPerItem;

                    dt.Rows.Add(dr);
                }
                long receiptId = item.SaveReceipt(
                    CustomerId,
                    GrandTotal,
                    Discount,
                    NetTotal,
                    Payment,
                    Arearrs.ToString(),
                    txtComments.Text,
                    txtPurpose.Text,
                    dt,
                    chkIsReturn.Checked, txtReturnReceiptNo.Text);

                UserLog.Log(Common.CURRENT_USER.Id, chkIsReturn.Checked ? UserActions.Made_A_Return_Receipt : UserActions.Made_A_Sale_Receipt,
                    string.Format("Customer : {0} ,  Receipt No : {1}", chkCash.Checked ? txtCashName.Text : lblCustomerName.Text, receiptId));

                DialogResult dialogue = MessageBox.Show("Receipt has been saved sucessfully." + Environment.NewLine + "Do you want to print ?", "Sale Completed", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (dialogue == DialogResult.Yes)
                {
                    ReceiptViewer receipt = new ReceiptViewer(new ReportInfo { Id = receiptId, Report = Report.Receipt });
                    receipt.ShowDialog();

                }
                else
                {
                }
                ResetReceipt();
                chkIsReturn.Checked = false;
                BindAllItemsGrid();
                lblNextReceiptNo.Text = Common.GetNextId(Modules.Receipt).ToString();

            }
            else
            {
                MessageBox.Show("Erroe! No Item for receipt...", "No Item for receipt", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #9
0
 private void btnCompanyListPrint_Click(object sender, EventArgs e)
 {
     if (Status_Supplier == 0)
     {
         if (dgvData.Rows.Count > 0)
         {
             string options = "0,1";
             if (chkOnlyActive.Checked)
                 options = "1,1";
             ReportInfo info = new ReportInfo() { Options = options, Report = Report.CompanyCustomerList };
             ReceiptViewer print = new ReceiptViewer(info);
             print.ShowDialog();
         }
         else if (dgvData.Rows.Count == 0)
         {
             MessageBox.Show("Error! No Record Found." + Environment.NewLine + "Please Made a valid transactions for print", "Supplier Transaction", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else if (Status_Supplier != 0)
     {
         Common.ShowInvlaidCodeMessage(cbSearchByCode, Modules.Supplier);
     }
 }
Example #10
0
        void MakePayment()
        {
            try
            {

                decimal amount = 0;
                string companyId = string.IsNullOrEmpty(cbCompanies.ValueMember) ? string.Empty : cbCompanies.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCompanies.SelectedItem)).Row[cbCompanies.ValueMember]);//= cbCompanies.SelectedValue.ToString();
                string companyName = string.IsNullOrEmpty(cbCompanies.ValueMember) ? string.Empty : cbCompanies.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCompanies.SelectedItem)).Row[cbCompanies.DisplayMember]);//= cbCompanies.SelectedValue.ToString();
                if (!string.IsNullOrEmpty(companyId))
                {
                    if (decimal.TryParse(txtAmount.Text, out amount) & amount != 0)
                    {
                        if (!string.IsNullOrEmpty(txtComments.Text))
                        {
                            string strAmount = txtAmount.Text;
                            if (rbDebit.Checked)
                                strAmount = "-" + strAmount;
                            long TransactioId = comp.MakePayment(companyId, Common.FormateDateForDB(dtpDate.Value), strAmount, txtComments.Text);
                            if (TransactioId > 0)
                            {
                                UserLog.Log(Common.CURRENT_USER.Id, rbCredit.Checked ? UserActions.Made_Credit_Payment_To_Supplier : UserActions.Made_Debit_Payment_To_Supplier, string.Format("Supplier : {0} , Amount : {1}, TransactionId : {2}", companyName, strAmount, TransactioId));
                                ResetPayment();
                                lblTransactionNo.Text = Common.GetNextId(Modules.Payment).ToString();
                                string msg = "Payment made successfully." + Environment.NewLine +
                                    "Do you want to print?";
                                if (MessageBox.Show(msg, "Payment Successfully Completed", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                                    == System.Windows.Forms.DialogResult.Yes)
                                {

                                    ReportInfo info = new ReportInfo() { Id = TransactioId, Report = Report.Payment, Options = "0" };
                                    ReceiptViewer print = new ReceiptViewer(info);
                                    print.ShowDialog();
                                }
                            }
                            else
                            {
                                MessageBox.Show("Operation could not be completed.", "Could not compete", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Comments are Mendatory.", "Comments are Mendatory", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            txtComments.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("InValid Amount.Please specify a valid amount.", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txtAmount.Text = "0.00";
                        txtAmount.Focus();
                    }
                }
                else
                {
                    MessageBox.Show("Please select a Supplier to make a payment.", "Select Supplier", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #11
0
 void Save()
 {
     if (dgvItems.Rows.Count > 0)
     {
         string CompanyId = string.IsNullOrEmpty(cbCompanies.ValueMember) ? string.Empty : cbCompanies.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCompanies.SelectedItem)).Row[cbCompanies.ValueMember]);//Convert.ToString(cbCompanies.SelectedValue);
         string CompanyName = string.IsNullOrEmpty(cbCompanies.ValueMember) ? string.Empty : cbCompanies.SelectedItem == null ? string.Empty : Convert.ToString(((DataRowView)(cbCompanies.SelectedItem)).Row[cbCompanies.DisplayMember]);//Convert.ToString(cbCompanies.SelectedValue);
         string InvoiceNo = txtInvoiceNo.Text;
         if (string.IsNullOrEmpty(InvoiceNo))
         {
             MessageBox.Show("Error! Invoice No. is Empty." + Environment.NewLine + "Please Enter a Invoice Number", "Invoice Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         if (item.IsDuplictaeInvoiceNo(InvoiceNo, CompanyId))
         {
             MessageBox.Show(string.Format("Error! Invoice No [{0}] already exists for Supplier [{1}]." + Environment.NewLine + "Please Enter a valid Invoice Number", InvoiceNo, cbCompanies.Text), "Invoice Number", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return;
         }
         string GrandTotal = lblGrandTotal.Text;
         string Discount = txtExpenses.Text;
         string Payment = txtPayment.Text;
         string Arrears = lblArrears.Text;
         DataTable dt = item.SelectEmptyInvoiceDetailTable();
         foreach (DataGridViewRow row in dgvItems.Rows)
         {
             DataRow dr = dt.NewRow();
             dr["Id"] = row.Cells["colSerial"].Value;
             dr["ItemId"] = row.Cells["colItemId"].Value;
             dr["PurchasePrice"] = row.Cells["colPrice"].Value;
             dr["Quantity"] = row.Cells["colQuantity"].Value;
             dr["Total"] = row.Cells["colTotal"].Value;
             dr["Discount"] = row.Cells["colDiscount"].Value;
             dr["GrandTotal"] = row.Cells["colGrandTotal"].Value;
             dt.Rows.Add(dr);
         }
         ReportInfo reportInfo = new ReportInfo();
         long OrderNo = 0;
         long.TryParse(txtOrderNo.Text, out OrderNo);
         long Id = item.SaveInvoice(CompanyId, InvoiceNo, GrandTotal, Discount, Payment, Arrears, txtComments.Text, OrderNo.ToString(), dt, chkIsReturn.Checked);
         if (Id > 0)
         {
             UserLog.Log(Common.CURRENT_USER.Id, chkIsReturn.Checked ? UserActions.Made_A_Return_Invoice : UserActions.Made_A_Purchase_Invoice,
                 string.Format("Supplier : {0} ,  Invoice No : {1}", CompanyName, InvoiceNo));
             MessageBox.Show("Invoice Saved Sucessfully.....", "Saved Successfully", MessageBoxButtons.OK, MessageBoxIcon.Information);
             reportInfo.Id = Id;
             reportInfo.Report = Report.Invoice;
             ReceiptViewer receipt = new ReceiptViewer(reportInfo);
             receipt.ShowDialog();
             ResetInvoice();
         }
     }
     else
     {
         MessageBox.Show("Error! No Item for Invoice...", "No Item", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }