Chidiebere Mgbemena

Chidiebere Mgbemena

  • NA
  • 179
  • 12.8k

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
  1. namespace NSPM_Sales_Invoice  
  2. {  
  3. public partial class UpdateBill : Form  
  4. {  
  5. SqlConnection con = new SqlConnection(Properties.Settings.Default.NSPM_Sales_InvoiceCon);  
  6. SqlCommand cmd;  
  7. SqlDataAdapter da;  
  8. DataTable dt;  
  9. public UpdateBill()  
  10. {  
  11. InitializeComponent();  
  12. }  
  13. private void UpdateBill_Load(object sender, EventArgs e)  
  14. {  
  15. con.Open();  
  16. cmd = con.CreateCommand();  
  17. cmd.CommandType = CommandType.Text;  
  18. cmd.CommandText = "Select * From Tbl_RowData where JobNo like ('" + txtJobNo.Text + "%')";  
  19. cmd.ExecuteNonQuery();  
  20. dt = new DataTable();  
  21. da = new SqlDataAdapter(cmd);  
  22. da.Fill(dt);  
  23. dataGridView1.DataSource = dt;  
  24. con.Close();  
  25. dataGridView1.Columns[1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;  
  26. // Fill description form table to descrption combobox  
  27. cmbDescription.Select();  
  28. cmbDescription.Items.Clear();  
  29. con.Open();  
  30. cmd = con.CreateCommand();  
  31. cmd.CommandType = CommandType.Text;  
  32. cmd.CommandText = "Select ProName from tbl_Products order by ProName asc";  
  33. cmd.ExecuteNonQuery();  
  34. dt = new DataTable();  
  35. da = new SqlDataAdapter(cmd);  
  36. da.Fill(dt);  
  37. foreach (DataRow dr in dt.Rows)  
  38. {  
  39. cmbDescription.Items.Add(dr["ProName"].ToString());  
  40. }  
  41. con.Close();  
  42. }  
  43. private void txtUnitPrice_Leave(object sender, EventArgs e)  
  44. {  
  45. CalGoodValue();  
  46. }  
  47. public void CalGoodValue()  
  48. {  
  49. double a1, b1, i;  
  50. double.TryParse(txtUnitPrice.Text, out a1);  
  51. double.TryParse(txtQuantity.Text, out b1);  
  52. i = a1 * b1;  
  53. if (1 > 0)  
  54. {  
  55. txtGoodValue.Text = i.ToString("C").Remove(0, 1);  
  56. }  
  57. }  
  58. private void txtQuantity_Leave(object sender, EventArgs e)  
  59. {  
  60. CalGoodValue();  
  61. }  
  62. private void LoadSerialNo()  
  63. {  
  64. int i = 1;  
  65. foreach (DataGridViewRow row in dataGridView1.Rows)  
  66. {  
  67. row.Cells[0].Value = i; i++;  
  68. }  
  69. }  
  70. private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)  
  71. {  
  72. LoadSerialNo();  
  73. }  
  74. int i;  
  75. private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)  
  76. {  
  77. i = e.RowIndex;  
  78. DataGridViewRow row = dataGridView1.Rows[i];  
  79. txtDeleteUpdate.Text = row.Cells[0].Value.ToString();  
  80. cmbDescription.Text = row.Cells[1].Value.ToString();  
  81. txtQuantity.Text = row.Cells[2].Value.ToString();  
  82. txtUnitPrice.Text = row.Cells[3].Value.ToString();  
  83. txtGoodValue.Text = row.Cells[4].Value.ToString();  
  84. }  
  85. private void btnDelete_Click(object sender, EventArgs e)  
  86. {  
  87. foreach (DataGridViewRow row in dataGridView1.SelectedRows)  
  88. {  
  89. if (!row.IsNewRow) dataGridView1.Rows.Remove(row);  
  90. LoadSerialNo();  
  91. }  
  92. }  
  93. private void btnAdd_Click(object sender, EventArgs e)  
  94. {  
  95. //if txxtDeleteUpdate textbox is empty then add newrow else Update Selected row  
  96. if (txtDeleteUpdate.Text == "")  
  97. {  
  98. for (int i = 0; i < dataGridView1.Rows.Count - 1; i++)  
  99. {  
  100. dataGridView1.Rows[1].Cells[1].Value = (i + 1).ToString();  
  101. }  
  102. DataTable dt = dataGridView1.DataSource as DataTable;  
  103. DataRow row1 = dt.NewRow();  
  104. row1[1] = cmbDescription.Text.ToString();  
  105. row1[2] = txtQuantity.Text.ToString();  
  106. row1[3] = txtUnitPrice.Text.ToString();  
  107. Arow1[4] = txtGoodValue.Text.ToString();  
  108. row1[5] = txtCustomer.Text.ToString();  
  109. row1[6] = txtJobNo.Text.ToString();  
  110. cmbDescription.Focus();  
  111. dt.Rows.Add(row1);  
  112. }  
  113. else  
  114. {  
  115. DataGridViewRow row = dataGridView1.Rows[i];  
  116. row.Cells[1].Value = cmbDescription.Text;  
  117. row.Cells[2].Value = txtQuantity.Text;  
  118. row.Cells[3].Value = txtUnitPrice.Text;  
  119. row.Cells[4].Value = txtGoodValue.Text;  
  120. row.Cells[5].Value = txtCustomer.Text;  
  121. row.Cells[6].Value = txtJobNo.Text; 

 
ERROR 2
codes

  1. namespace NSPM_Sales_Invoice  
  2. {  
  3. public partial class Dashboard : Form  
  4. {  
  5. public Dashboard()  
  6. {  
  7. InitializeComponent();  
  8. }  
  9. private void productsToolStripMenuItem_Click(object sender, EventArgs e)  
  10. {  
  11. Products p = new Products();  
  12. p.MdiParent = this;  
  13. p.Show();  
  14. }  
  15. private void newToolStripMenuItem_Click(object sender, EventArgs e)  
  16. {  
  17. frmNewBill nb = new frmNewBill();  
  18. nb.MdiParent = this;  
  19. nb.Show();  
  20. }  
  21. private void viewBillsToolStripMenuItem_Click(object sender, EventArgs e)  
  22. {  
  23. ViewBills vb = new ViewBills();  
  24. vb.MdiParent = this;  
  25. vb.Show();  

ERROR 3
 
 
login codes
  1. namespace NSPM_Sales_Invoice  
  2. {  
  3. static class Program  
  4. {  
  5. ///  
  6. /// The main entry point for the application.  
  7. ///  
  8. [STAThread]  
  9. static void Main()  
  10. {  
  11. Application.EnableVisualStyles();  
  12. Application.SetCompatibleTextRenderingDefault(false);  
  13. Application.Run(new Login());  
  14. }
Login codes
  1. namespace NSPM_Sales_Invoice  
  2. {  
  3. public partial class Login : Form  
  4. {  
  5. public Login()  
  6. {  
  7. InitializeComponent();  
  8. }  
  9. private void Login_Load(object sender, EventArgs e)  
  10. {  
  11. }  
  12. private void btnLogin_Click(object sender, EventArgs e)  
  13. {  
  14. SqlConnection sqlcon = new SqlConnection(@"Data Source=Chidiebere;Initial Catalog=NSPM_Sales_Invoice_DB;Integrated Security=True");  
  15. String query = "Select * from tbl_Login Where username = '" + txtUserName.Text.Trim() + "' and password = '" + txtPassword.Text.Trim() + "'";  
  16. SqlDataAdapter sda = new SqlDataAdapter(query, sqlcon);  
  17. DataTable dtbl = new DataTable();  
  18. sda.Fill(dtbl);  
  19. if (dtbl.Rows.Count == 1)  
  20. {  
  21. Dashboard objDashboard = new Dashboard();  
  22. this.Hide();  
  23. objDashboard.Show();  
  24. }  
  25. else  
  26. {  
  27. MessageBox.Show("Check your Username and Password");  
  28. }  
  29. }  
  30. private void btnExit_Click(object sender, EventArgs e)  
  31. {  
  32. this.Close();  
  33. }  
  34. }  


Answers (5)