TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chidiebere Mgbemena
NA
179
14.2k
JobNo wont appear on the text box when imputed
May 26 2020 10:29 AM
When I input JobNo. example 04542, it won't appear on the textbox when I click on add button. Please check if anything is missing.
Thanks for always coming to my aid.
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Threading.Tasks;
using
System.Windows.Forms;
using
System.Data.SqlClient;
namespace
NSPM_Sales_Invoice
{
public
partial
class
frmNewBill : Form
{
SqlConnection con =
new
SqlConnection(Properties.Settings.Default.NSPM_Sales_InvoiceCon);
SqlCommand cmd;
public
frmNewBill()
{
InitializeComponent();
txtDeleteUpdate.Visible =
false
;
}
{
cmbDescription.Select();
cmbDescription.Items.Clear();
con.Open();
cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"Select ProName from tbl_Products order by ProName asc"
;
cmd.ExecuteNonQuery();
DataTable dt =
new
DataTable();
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
da.Fill(dt);
foreach
(DataRow dr
in
dt.Rows)
{
cmbDescription.Items.Add(dr[
"ProName"
].ToString());
}
con.Close();
dataGridView1.Columns[5].Visible =
false
;
dataGridView1.Columns[6].Visible =
false
;
}
private
void
btnAdd_Click(
object
sender, EventArgs e)
{
if
(cmbDescription.Text ==
""
)
{
MessageBox.Show(
"Description is Empty"
);
}
else
if
(txtQuantity.Text ==
""
)
{
MessageBox.Show(
"Quantity is Empty"
);
}
else
if
(txtUnitPrice.Text ==
""
)
{
MessageBox.Show(
"Unit Price is Empty"
);
}
else
if
(txtJobNo.Text ==
""
)
{
MessageBox.Show(
"JobNo is Empty"
);
if
(txtDeleteUpdate.Text ==
""
)
{
int
row = 0;
dataGridView1.Rows.Add();
row = dataGridView1.Rows.Count - 1;
dataGridView1[
"Description"
, row].Value = cmbDescription.Text;
dataGridView1[
"Quantity"
, row].Value = txtQuantity.Text;
dataGridView1[
"UnitPrice"
, row].Value = txtUnitPrice.Text;
dataGridView1[
"GoodValue"
, row].Value = txtGoodValue.Text;
dataGridView1[
"JobNo"
, row].Value = txtJobNo.Text;
dataGridView1[
"Date"
, row].Value = dateTimePicker1.Value.ToString(
"yyyy-MM-dd"
);
dataGridView1.Refresh();
cmbDescription.Focus();
if
(dataGridView1.Rows.Count > 0)
{
dataGridView1.CurrentCell = dataGridView1.Rows[dataGridView1.Rows.Count - 1].Cells[1];
}
}
else
{
btnAdd.Text =
"UPDATE"
;
int
i = 0;
DataGridViewRow row = dataGridView1.Rows[i];
row.Cells[1].Value = cmbDescription.Text;
row.Cells[2].Value = txtQuantity.Text;
row.Cells[3].Value = txtUnitPrice.Text;
row.Cells[4].Value = txtGoodValue.Text;
row.Cells[5].Value = txtJobNo.Text;
btnAdd.Text =
"ADD"
;
}
cleartextbox();
gridGoodValue();
}
}
private
void
dataGridView1_RowPostPaint(
object
sender, DataGridViewRowPostPaintEventArgs e)
{
this
.dataGridView1.Rows[e.RowIndex].Cells[0].Value = (e.RowIndex + 1).ToString();
}
int
i;
private
void
dataGridView1_CellDoubleClick(
object
sender, DataGridViewCellEventArgs e)
{
i = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[i];
cmbDescription.Text = row.Cells[1].Value.ToString();
txtQuantity.Text = row.Cells[2].Value.ToString();
txtUnitPrice.Text = row.Cells[3].Value.ToString();
txtGoodValue.Text = row.Cells[4].Value.ToString();
txtJobNo.Text = row.Cells[5].Value.ToString();
txtDeleteUpdate.Text = row.Cells[0].Value.ToString();
btnAdd.Text =
"UPDATE"
;
}
private
void
btnDelete_Click(
object
sender, EventArgs e)
{
if
(txtDeleteUpdate.Text ==
""
)
{
MessageBox.Show(
"Select Product to Delete"
);
}
else
{
foreach
(DataGridViewRow row
in
dataGridView1.SelectedRows)
{
if
(!row.IsNewRow) dataGridView1.Rows.Remove(row);
}
}
btnAdd.Text =
"ADD"
;
gridGoodValue();
cleartextbox();
}
public
void
cleartextbox()
{
cmbDescription.Text =
""
;
txtQuantity.Text =
""
;
txtUnitPrice.Text =
""
;
txtGoodValue.Text =
""
;
txtJobNo.Text =
""
;
txtDeleteUpdate.Text =
""
;
}
}
Reply
Answers (
4
)
Evolving thought process and design thinking
How to format datagridview to shown correct format number