Exemplo n.º 1
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvTransaction.SelectedRows.Count > 0)
                {
                    DataRow row = ((DataTable)dgvTransaction.DataSource).Rows[dgvTransaction.SelectedRows[0].Index];
                    frmTransactionItemsGrid fr = new frmTransactionItemsGrid();
                    fr.row           = row;
                    fr.Stat          = Stat;
                    fr.tranTYPE      = txtTransactionType.Text;
                    fr.thisStat      = FrmCompany.itgEdit;
                    fr.StartPosition = FormStartPosition.CenterParent;
                    if (Stat == FrmCompany.TransAdd)
                    {
                        fr.Stat    = FrmCompany.TransAdd;
                        fr.TransNo = txtTransactionNo.Text;
                    }
                    else if (Stat == FrmCompany.TransEdit)
                    {
                        fr.Stat    = FrmCompany.TransEdit;
                        fr.TransNo = id.ToString();
                    }

                    if (cmbInvoice.SelectedIndex == 2)
                    {
                        fr.bool_Labour = true;
                    }
                    else
                    {
                        fr.bool_Labour = false;
                    }

                    fr.ShowDialog();
                }
                RefreshItems();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrWhiteSpace(txtTransactionNo.Text))
                {
                    if (cbmCustomer.SelectedIndex < 0)
                    {
                        MessageBox.Show("Select Customer First.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        string ext = "";
                        if (txtTransactionType.Text == "Purchase")
                        {
                            ext = " and tranCustID = " + custID[cbmCustomer.SelectedIndex];
                        }
                        AIO.command = "select count(id) from Trans where tranNo='" + txtTransactionNo.Text + "'" + ext;
                        var tmp = Convert.ToInt32(a1.cmdexesc());
                        if (Stat == FrmCompany.TransEdit)
                        {
                            tmp = 0;
                        }
                        if (tmp > 0)
                        {
                            MessageBox.Show("Transaction No is already exist.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            //txtTransactionNo.Focus();
                        }
                        else
                        {
                            frmTransactionItemsGrid fr = new frmTransactionItemsGrid();
                            fr.StartPosition = FormStartPosition.CenterParent;

                            fr.tranTYPE = txtTransactionType.Text;
                            fr.thisStat = FrmCompany.itgAdd;
                            if (Stat == FrmCompany.TransAdd)
                            {
                                fr.Stat    = FrmCompany.TransAdd;
                                fr.TransNo = txtTransactionNo.Text;
                            }
                            else if (Stat == FrmCompany.TransEdit)
                            {
                                fr.Stat    = FrmCompany.TransEdit;
                                fr.TransNo = id.ToString();
                            }

                            if (cmbInvoice.SelectedIndex == 2)
                            {
                                fr.bool_Labour = true;
                            }
                            else
                            {
                                fr.bool_Labour = false;
                            }
                            fr.ShowDialog();

                            RefreshItems();
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Transaction No. Can't be Blank or Null.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }