private void formPucrchase_Load(object sender, EventArgs e)
        {
            this.MinimumSize = this.Size;

            DAL.Pucrchase pucrchase = new Pucrchase();
            pucrchase.Search    = textBoxSearch.Text;
            proGrid1.DataSource = pucrchase.Select().Tables[0];
        }
        private void formPucrchaseReport_Load(object sender, EventArgs e)
        {
            this.MinimumSize = this.Size;

            DAL.Pucrchase pucrchase = new Pucrchase();
            //proGrid1.DataSource = pucrchase.Select().Tables[0];

            //ReportDocument reportDocument = new ReportDocument();
            CrystalReportPurchase pr = new CrystalReportPurchase();

            pr.Database.Tables["Purches"].SetDataSource(pucrchase.Select().Tables[0]);
            //reportDocument.Load("C:\\Users\\Sunil\\Documents\\Visual Studio 2013\\Projects\\Windows Form\\Point Of Sale\\Point Of Sale\\Point Of Sale\\Presentation\\PucrchaseReport.rpt");
            crystalReportPucrchase.ReportSource = pr;
            crystalReportPucrchase.Refresh();
        }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            if (proGrid1.SelectedRows.Count <= 0)
            {
                return;
            }

            DialogResult deletePro = MessageBox.Show("Are you sure?", "Comfirmation.", MessageBoxButtons.YesNoCancel,
                                                     MessageBoxIcon.Question);

            if (deletePro != DialogResult.Yes)
            {
                return;
            }

            DAL.Pucrchase pucrchase = new Pucrchase();

            string ids = "";

            for (int i = 0; i < proGrid1.SelectedRows.Count; i++)
            {
                ids += proGrid1.SelectedRows[i].Cells["ColNumber"].Value.ToString() + ", ";
            }

            ids = ids.Substring(0, ids.Length - 2);

            if (pucrchase.Delete(ids))
            {
                MessageBox.Show("Product is delete.");
                buttonSearch.PerformClick();
            }
            else
            {
                MessageBox.Show(pucrchase.Error);
            }
        }
コード例 #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            int error = 0;

            errorProvider.Clear();

            //if (textBoxNumber.Text == "")
            //{
            //    error++;
            //    errorProvider.SetError(textBoxNumber, "Required");
            //}

            if (comboBoxLedger.Text == "")
            {
                error++;
                errorProvider.SetError(comboBoxLedger, "Required");
            }

            if (dateTimePickerPucrchase.Text == "")
            {
                error++;
                errorProvider.SetError(dateTimePickerPucrchase, "Required");
            }

            if (comboBoxEmployee.Text == "")
            {
                error++;
                errorProvider.SetError(comboBoxEmployee, "Required");
            }

            if (textBoxTotal.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxTotal, "Required");
            }

            if (textBoxVat.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxVat, "Required");
            }

            if (textBoxDiscound.Text == "")
            {
                error++;
                errorProvider.SetError(textBoxDiscound, "Required");
            }

            if (dataGridViewPucrchase.Rows.Count < 2)
            {
                error++;
                errorProvider.SetError(dataGridViewPucrchase, "Entered some item.");
            }

            if (error > 0)
            {
                return;
            }

            DAL.Pucrchase pucrchase = new Pucrchase();
            //pucrchase.Number = textBoxNumber.Text;
            pucrchase.LedgerId   = Convert.ToInt32(comboBoxLedger.SelectedValue);
            pucrchase.DateTime   = Convert.ToDateTime(dateTimePickerPucrchase.Text);
            pucrchase.EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue);
            pucrchase.Total      = Convert.ToDouble(textBoxTotal.Text);
            pucrchase.Discount   = Convert.ToDouble(textBoxDiscound.Text);
            pucrchase.Vat        = Convert.ToDouble(textBoxVat.Text);

            if (pucrchase.Insert())
            {
                for (int i = 0; i < dataGridViewPucrchase.Rows.Count - 1; i++)
                {
                    DAL.PucrchaseDetails pucrchaseDetails = new PucrchaseDetails();
                    pucrchaseDetails.PucrchaseId = pucrchase.LastId;
                    pucrchaseDetails.ProductId   = Convert.ToInt32(dataGridViewPucrchase.Rows[i].Cells["ColProduct"].Value);
                    pucrchaseDetails.Qty         = Convert.ToInt32(dataGridViewPucrchase.Rows[i].Cells["ColQty"].Value);
                    pucrchaseDetails.Rate        = Convert.ToDouble(dataGridViewPucrchase.Rows[i].Cells["ColRate"].Value);
                    pucrchaseDetails.Insert();
                }

                DAL.Transaction transactionTwo = new Transaction();
                transactionTwo.DateTime   = dateTimePickerPucrchase.Value;
                transactionTwo.EmployeeId = pucrchase.EmployeeId;
                transactionTwo.LedgerId   = pucrchase.LedgerId;
                transactionTwo.Number     = "Automated transction number" + pucrchase.Number;
                transactionTwo.Reference  = Convert.ToString(pucrchase.Number);
                transactionTwo.Remarks    = "Automatic transaction during pucrchase";
                transactionTwo.Debit      = 0;
                transactionTwo.Credit     = Convert.ToDouble(textBoxGrandTotal.Text);

                if (!transactionTwo.Insert())
                {
                    MessageBox.Show(transactionTwo.Error);
                }


                double paid = 0;

                try
                {
                    paid = Convert.ToDouble(textBoxPaid.Text);
                    DAL.Transaction transaction = new Transaction();
                    transaction.DateTime   = dateTimePickerPucrchase.Value;
                    transaction.EmployeeId = pucrchase.EmployeeId;
                    transaction.LedgerId   = pucrchase.LedgerId;
                    transaction.Number     = "Automated transction number" + pucrchase.Number;
                    transaction.Reference  = Convert.ToString(pucrchase.Number);
                    transaction.Remarks    = "Automatic transaction during pucrchase";
                    transaction.Debit      = paid;
                    transaction.Credit     = 0;

                    if (!transaction.Insert())
                    {
                        MessageBox.Show(transaction.Error);
                    }
                }
                catch (Exception)
                {
                }


                MessageBox.Show("Pucrchase Save");
                dataGridViewPucrchase.Rows.Clear();
                //textBoxNumber.Text = "";
                comboBoxLedger.Text          = "";
                dateTimePickerPucrchase.Text = "";
                comboBoxEmployee.Text        = "";
                textBoxTotal.Text            = "";
                textBoxGrandTotal.Text       = "";
            }

            else
            {
                MessageBox.Show(pucrchase.Error);
            }
        }
 private void textBoxSearch_TextChanged(object sender, EventArgs e)
 {
     DAL.Pucrchase pucrchase = new Pucrchase();
     pucrchase.Search    = textBoxSearch.Text;
     proGrid1.DataSource = pucrchase.Select().Tables[0];
 }