コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!validateData())
            {
                return;
            }
            try
            {
                string sqlstr;
                int    NoOfRows = 0;

                if (companyId > 0)
                {
                    sqlstr = "SELECT * from userDetails WHERE userId='" + companyId + "'";
                    DataSet ds = m1.selectData(sqlstr);

                    DialogResult drDuplicateInsert = MessageBox.Show("Do you want to update Company : " + tbCompanyName.Text + " ?"
                                                                     , "Alert", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (drDuplicateInsert == DialogResult.Yes)
                    {
                        sqlstr = "UPDATE userDetails set companyname='" + tbCompanyName.Text + "', name='" + tbContactPerson.Text +
                                 "', address='" + tbAddress.Text + "', landmark='" + tbLandmark.Text + "', city='" + tbCity.Text +
                                 "', state='" + tbState.SelectedItem + "', code='" + tbCode.Text + "', pincode='" + tbPinCode.Text +
                                 "', gstin='" + tbGstin.Text + "', email='" + tbEmail.Text + "', phoneNumber='" + tbContact.Text +
                                 "', panno='" + tbPanNo.Text + "', bankname='" + tbBankName.Text + "', branchname='" + tbBranch.Text +
                                 "', accountno='" + tbAccountNo.Text + "', ifsccode='" + tbIfscCode.Text + "' WHERE userId='" + companyId + "'";
                        NoOfRows = m1.Ins_Upd_Del(sqlstr);
                    }
                }
                else
                {
                    sqlstr = "INSERT INTO userDetails(companyname, name, address, landmark, city, state, code, pincode, gstin, email, phoneNumber, panno, bankname, branchname, accountno, ifsccode)" +
                             "VALUES('" + tbCompanyName.Text + "', '" + tbContactPerson.Text + "', '" + tbAddress.Text + "', '" + tbLandmark.Text + "', '" + tbCity.Text + "', '" + tbState.SelectedItem + "','"
                             + tbCode.Text + "', '" + tbPinCode.Text + "', '" + tbGstin.Text + "', '" + tbEmail.Text + "', '" + tbContact.Text + "', '" + tbPanNo.Text + "','"
                             + tbBankName.Text + "', '" + tbBranch.Text + "', '" + tbAccountNo.Text + "', '" + tbIfscCode.Text + "')";
                    NoOfRows = m1.Ins_Upd_Del(sqlstr);
                }
                if (NoOfRows > 0)
                {
                    //this.CompanyName = tbCompanyName.Text;
                    //this.CompanyAddress = tbAddress.Text;
                    //this.CompanyEmail = tbEmail.Text;
                    //this.CompanyContact = tbContact.Text;

                    MessageBox.Show("Details saved successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Failed to save details!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.DialogResult = System.Windows.Forms.DialogResult.Abort;
                    return;
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Error :" + e1.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: roymanoj/gst-billing
        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);
                }
            }
        }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (!validateData())
     {
         return;
     }
     try
     {
         DataSet ds       = productExists(tbProdDes.Text);
         int     NoOfRows = 0;
         string  sqlstr;
         if (ds != null && ds.Tables[0].Rows.Count > 0)
         {
             DialogResult result = MessageBox.Show("Do you want to update existing information?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 sqlstr = "UPDATE productDetails set productName='" + tbProdDes.Text + "', hsnCode='" + tbProdHsnCode.Text + "', productPrice='" + tbProdRate.Text +
                          "', productUnit='" + tbProdUnit.Text + "' WHERE productId='" + ds.Tables[0].Rows[0][0] + "' AND userId= '" + BaseModel.Instance.CompanyId + "'";
                 NoOfRows = m1.Ins_Upd_Del(sqlstr);
             }
         }
         else
         {
             sqlstr = "INSERT INTO productDetails(productName, hsnCode, productPrice, productUnit, userId)" +
                      "VALUES('" + tbProdDes.Text + "', '" + tbProdHsnCode.Text + "', " + tbProdRate.Text + ", '" + tbProdUnit.Text + "', '" + BaseModel.Instance.CompanyId.ToString() + "' )";
             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);
             return;
         }
     }
     catch (Exception e1)
     {
         MessageBox.Show("Error :" + e1.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidateData())
            {
                return;
            }
            try
            {
                DataSet ds       = customerExists(tbName.Text);
                int     NoOfRows = 0;
                string  sqlstr;
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    DialogResult result = MessageBox.Show("Do you want to update existing information?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        sqlstr = "UPDATE customerDetails set custname='" + tbName.Text + "', custContactPerson='" + tbContact.Text + "', custaddress='" + tbAddress.Text + "', custlandmark='" + tbLandmark.Text +
                                 "', custcity='" + tbCity.Text + "', custstate='" + tbState.Text + "', custcode='" + tbCode.Text +
                                 "', custpincode='" + tbPinCode.Text + "', custemail='" + tbEmail.Text + "', custphoneNumber='" + tbPhoneNo.Text +
                                 "', custgstin='" + tbGstin.Text + "', custAadharNo='" + tbAadharNo.Text + "', custPanno='" + tbPanNo.Text +
                                 "', custpaymentTermName='" + tbPayment.Text +
                                 "', shipname='" + tbShipName.Text + "', shipContactPerson='" + tbShipContact.Text + "', shipaddress='" + tbShipAddress.Text +
                                 "', shiplandmark='" + tbShipLandmark.Text + "', shipcity='" + tbShipCity.Text + "', shipstate='" + tbShipState.Text +
                                 "', shipcode='" + tbShipCode.Text + "', shippincode='" + tbShipPinCode.Text + "', shipemail='" + tbShipEmail.Text + "', shipphoneNumber='" + tbShipPhone.Text +
                                 "', shipgstin='" + tbShipGstin.Text + "', shipAadharNo='" + tbShipAadhar.Text + "', shipPanno='" + tbShipPanNumber.Text +
                                 "', shippaymentTermName='" + tbShipPayment.Text + "' WHERE custname='" + tbName.Text + "' AND userId='" + baseModel.CompanyId + "'";
                        NoOfRows = m1.Ins_Upd_Del(sqlstr);
                    }
                }
                else
                {
                    sqlstr = "INSERT INTO customerDetails(custname, custContactPerson, custaddress, custlandmark, custcity, custstate, " +
                             "custcode, custpincode, custemail, custphoneNumber, custgstin, custAadharNo, custPanno, custpaymentTermName, " +
                             "shipname, shipContactPerson, shipaddress, shiplandmark, shipcity, shipstate, shipcode, shippincode, " +
                             "shipemail, shipphoneNumber, shipgstin, shipAadharNo, shipPanno, shippaymentTermName, userId)" +
                             "VALUES('" + tbName.Text + "', '" + tbContact.Text + "', '" + tbAddress.Text + "','" + tbLandmark.Text + "', '" + tbCity.Text + "', '" + tbState.Text + "', '" + tbCode.Text + "', '"
                             + tbPinCode.Text + "', '" + tbEmail.Text + "', '" + tbPhoneNo.Text + "','" + tbGstin.Text + "', '" + tbAadharNo.Text + "', '" + tbPanNo.Text + "', '" + tbPayment.Text + "', '"
                             + tbShipName.Text + "', '" + tbShipContact.Text + "', '" + tbShipAddress.Text + "','" + tbShipLandmark.Text + "', '" + tbShipCity.Text + "', '" + tbShipState.Text + "', '"
                             + tbShipCode.Text + "', '" + tbShipPinCode.Text + "', '" + tbShipEmail.Text + "', '" + tbShipPhone.Text + "','" + tbShipGstin.Text + "', '" + tbShipAadhar.Text + "', '"
                             + tbShipPanNumber.Text + "', '" + tbShipPayment.Text + "', '" + baseModel.CompanyId + "')";
                    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);
                    return;
                }
            }
            catch (Exception e1)
            {
                MessageBox.Show("Error :" + e1.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //Invoice invoice = new Invoice();
            //invoice.Show();
            //this.Hide();
        }