private bool checkCompanyExists() { string sqlstr = "SELECT * from userDetails"; DataSet ds = m1.selectData(sqlstr); //autoCompleteStrings.Clear(); if (ds != null && ds.Tables[0].Rows.Count > 0) { return(true); //foreach (DataRow row in ds.Tables[0].Rows) //{ // autoCompleteStrings.Add((string)row["companyname"]); //} //tbCompanyName.AutoCompleteCustomSource = autoCompleteStrings; //this.CompanyName = Convert.ToString(ds.Tables[0].Rows[0]["companyname"]); //this.CompanyAddress = Convert.ToString(ds.Tables[0].Rows[0]["address"]) + "," + // Convert.ToString(ds.Tables[0].Rows[0]["landmark"]) + "," + // Convert.ToString(ds.Tables[0].Rows[0]["city"]) + "," + // Convert.ToString(ds.Tables[0].Rows[0]["state"]); //this.CompanyEmail = Convert.ToString(ds.Tables[0].Rows[0]["email"]); //this.CompanyContact = Convert.ToString(ds.Tables[0].Rows[0]["phoneNumber"]); } return(false); }
private void btnChange_Click(object sender, EventArgs e) { try { if (ValidateInputs()) { string sqlstr = "SELECT * FROM loginDetails WHERE username = '******' AND password = '******' "; DataSet ds = m1.selectData(sqlstr); if (ds.Tables[0].Rows.Count > 0) { sqlstr = "UPDATE loginDetails set username='******',password='******' WHERE loginId = " + Convert.ToInt32(ds.Tables[0].Rows[0]["loginId"]) + " "; int NoOfRows = m1.Ins_Upd_Del(sqlstr); if (NoOfRows > 0) { MessageBox.Show("Details saved successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Failed to save details!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("Please enter valid credentials!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception e1) { MessageBox.Show("Error :" + e1.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOK_Click(object sender, EventArgs e) { try { string sqlstr = "SELECT * FROM loginDetails WHERE username = '******' "; DataSet ds = m1.selectData(sqlstr); if (ds.Tables[0].Rows.Count > 0) { string username = Convert.ToString(ds.Tables[0].Rows[0]["username"]); string password = Convert.ToString(ds.Tables[0].Rows[0]["password"]); if (tbUserName.Text != username || tbPassword.Text != password) { MessageBox.Show("Please enter valid credentials!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { this.Hide(); SelectFirm companySelect = new SelectFirm(); companySelect.Show(this); } } else { MessageBox.Show("Please enter valid credentials!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception e1) { MessageBox.Show("Error :" + e1.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnDeleteCust_Click(object sender, EventArgs e) { if (dgvCustomer.SelectedRows.Count > 0) { DataGridViewRow row = dgvCustomer.SelectedRows[0]; string sqlstr = "DELETE FROM customerDetails WHERE custname='" + (string)dgvCustomer.SelectedRows[0].Cells[0].Value + "' AND userId='" + BaseModel.Instance.CompanyId + "'"; string sqlStrCustId = "SELECT custId FROM customerDetails WHERE custname='" + (string)dgvCustomer.SelectedRows[0].Cells[0].Value + "' AND userId='" + BaseModel.Instance.CompanyId + "'"; DataSet ds = m1.selectData(sqlStrCustId); if (ds != null && ds.Tables[0].Rows.Count > 0) { string custId = ds.Tables[0].Rows[0][0].ToString(); sqlStrCustId = "SELECT invoiceNo FROM invoiceDetails WHERE custId='" + custId + "' AND userId='" + BaseModel.Instance.CompanyId + "'"; DataSet ds1 = m1.selectData(sqlStrCustId); if (ds1 != null && ds1.Tables[0].Rows.Count > 0) { MessageBox.Show("Customer can not be deleted as invoice for this customer exists.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } DialogResult result = MessageBox.Show("Do you really want to delete this customer?", "Warning!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { int no_of_rows = m1.Ins_Upd_Del(sqlstr); dgvCustomer.Rows.RemoveAt(dgvCustomer.SelectedRows[0].Index); } } }
private void updateAutoCompleteFirms() { string sqlstr = "SELECT * from userDetails"; DataSet ds = m1.selectData(sqlstr); autoCompleteStrings.Clear(); if (ds != null && ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { autoCompleteStrings.Add((string)row["companyname"]); } tbSelectedFirm.DataSource = null; tbSelectedFirm.DataSource = autoCompleteStrings; tbSelectedFirm.SelectedIndex = 0; } tbSelectedYear.SelectedIndex = 0; }
public DataSet customerExists(string name) { string sqlstr = "SELECT * FROM customerDetails WHERE custname ='" + name + "' AND userId='" + baseModel.CompanyId + "'"; DataSet ds = m1.selectData(sqlstr); if (ds.Tables[0].Rows.Count > 0) { return(ds); } return(null); }
public DataSet productExists(string name) { string sqlstr = "SELECT * FROM productDetails WHERE productName='" + name + "' and userId='" + BaseModel.Instance.CompanyId + "' "; DataSet ds = m1.selectData(sqlstr); if (ds.Tables[0].Rows.Count > 0) { return(ds); } return(null); }