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
some couple of errors in billing system
May 31 2020 7:09 PM
Hello guyz,
Please i need codes and solution on how to resolve this errors in my simple billing system
Many thanks.
codes
namespace
NSPM_Sales_Invoice
{
public
partial
class
UpdateBill : Form
{
SqlConnection con =
new
SqlConnection(Properties.Settings.Default.NSPM_Sales_InvoiceCon);
SqlCommand cmd;
SqlDataAdapter da;
DataTable dt;
public
UpdateBill()
{
InitializeComponent();
}
private
void
UpdateBill_Load(
object
sender, EventArgs e)
{
con.Open();
cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText =
"Select * From Tbl_RowData where JobNo like ('"
+ txtJobNo.Text +
"%')"
;
cmd.ExecuteNonQuery();
dt =
new
DataTable();
da =
new
SqlDataAdapter(cmd);
da.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
// Fill description form table to descrption combobox
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();
dt =
new
DataTable();
da =
new
SqlDataAdapter(cmd);
da.Fill(dt);
foreach
(DataRow dr
in
dt.Rows)
{
cmbDescription.Items.Add(dr[
"ProName"
].ToString());
}
con.Close();
}
private
void
txtUnitPrice_Leave(
object
sender, EventArgs e)
{
CalGoodValue();
}
public
void
CalGoodValue()
{
double
a1, b1, i;
double
.TryParse(txtUnitPrice.Text,
out
a1);
double
.TryParse(txtQuantity.Text,
out
b1);
i = a1 * b1;
if
(1 > 0)
{
txtGoodValue.Text = i.ToString(
"C"
).Remove(0, 1);
}
}
private
void
txtQuantity_Leave(
object
sender, EventArgs e)
{
CalGoodValue();
}
private
void
LoadSerialNo()
{
int
i = 1;
foreach
(DataGridViewRow row
in
dataGridView1.Rows)
{
row.Cells[0].Value = i; i++;
}
}
private
void
dataGridView1_RowsAdded(
object
sender, DataGridViewRowsAddedEventArgs e)
{
LoadSerialNo();
}
int
i;
private
void
dataGridView1_CellDoubleClick(
object
sender, DataGridViewCellEventArgs e)
{
i = e.RowIndex;
DataGridViewRow row = dataGridView1.Rows[i];
txtDeleteUpdate.Text = row.Cells[0].Value.ToString();
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();
}
private
void
btnDelete_Click(
object
sender, EventArgs e)
{
foreach
(DataGridViewRow row
in
dataGridView1.SelectedRows)
{
if
(!row.IsNewRow) dataGridView1.Rows.Remove(row);
LoadSerialNo();
}
}
private
void
btnAdd_Click(
object
sender, EventArgs e)
{
//if txxtDeleteUpdate textbox is empty then add newrow else Update Selected row
if
(txtDeleteUpdate.Text ==
""
)
{
for
(
int
i = 0; i < dataGridView1.Rows.Count - 1; i++)
{
dataGridView1.Rows[1].Cells[1].Value = (i + 1).ToString();
}
DataTable dt = dataGridView1.DataSource
as
DataTable;
DataRow row1 = dt.NewRow();
row1[1] = cmbDescription.Text.ToString();
row1[2] = txtQuantity.Text.ToString();
row1[3] = txtUnitPrice.Text.ToString();
Arow1[4] = txtGoodValue.Text.ToString();
row1[5] = txtCustomer.Text.ToString();
row1[6] = txtJobNo.Text.ToString();
cmbDescription.Focus();
dt.Rows.Add(row1);
}
else
{
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 = txtCustomer.Text;
row.Cells[6].Value = txtJobNo.Text;
ERROR 2
codes
namespace
NSPM_Sales_Invoice
{
public
partial
class
Dashboard : Form
{
public
Dashboard()
{
InitializeComponent();
}
private
void
productsToolStripMenuItem_Click(
object
sender, EventArgs e)
{
Products p =
new
Products();
p.MdiParent =
this
;
p.Show();
}
private
void
newToolStripMenuItem_Click(
object
sender, EventArgs e)
{
frmNewBill nb =
new
frmNewBill();
nb.MdiParent =
this
;
nb.Show();
}
private
void
viewBillsToolStripMenuItem_Click(
object
sender, EventArgs e)
{
ViewBills vb =
new
ViewBills();
vb.MdiParent =
this
;
vb.Show();
}
ERROR 3
login codes
namespace
NSPM_Sales_Invoice
{
static
class
Program
{
///
/// The main entry point for the application.
///
[STAThread]
static
void
Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(
false
);
Application.Run(
new
Login());
}
Login codes
namespace
NSPM_Sales_Invoice
{
public
partial
class
Login : Form
{
public
Login()
{
InitializeComponent();
}
private
void
Login_Load(
object
sender, EventArgs e)
{
}
private
void
btnLogin_Click(
object
sender, EventArgs e)
{
SqlConnection sqlcon =
new
SqlConnection(@
"Data Source=Chidiebere;Initial Catalog=NSPM_Sales_Invoice_DB;Integrated Security=True"
);
String query =
"Select * from tbl_Login Where username = '"
+ txtUserName.Text.Trim() +
"' and password = '"
+ txtPassword.Text.Trim() +
"'"
;
SqlDataAdapter sda =
new
SqlDataAdapter(query, sqlcon);
DataTable dtbl =
new
DataTable();
sda.Fill(dtbl);
if
(dtbl.Rows.Count == 1)
{
Dashboard objDashboard =
new
Dashboard();
this
.Hide();
objDashboard.Show();
}
else
{
MessageBox.Show(
"Check your Username and Password"
);
}
}
private
void
btnExit_Click(
object
sender, EventArgs e)
{
this
.Close();
}
}
}
Reply
Answers (
5
)
Search two words in datagrid C#
Copy to Clipboard is not working in button click event MVC5