예제 #1
0
        /// <summary>
        /// Name:InsertCustomer
        /// Description:in this method fire the insert query using stringbuilder
        /// Author:Monal shah
        /// created date:2010/09/30
        /// </summary>
        /// <returns>bool</returns>
        public bool InsertCustomer()
        {
            sbInsertValue = new StringBuilder();
            sbInsertValue.Append("Insert ");
            sbInsertValue.Append("Into ");
            sbInsertValue.Append("Customers ");
            sbInsertValue.Append("values");
            sbInsertValue.Append("(");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCustomerID);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCompanyName);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strContactName);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strContactTitle);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strAddress);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCity);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strRegion);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strPostalCode);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCountry);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strPhone);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strFax);
            sbInsertValue.Append("'");
            sbInsertValue.Append(")");

            objcl.GetSqlStmt = sbInsertValue.ToString();
            return(objcl.ExecuteNonQuery());//call ExecuteNonQuery method
        }
예제 #2
0
        /// <summary>
        /// Name:ListBoxValues
        /// Description:Fill the listbox with selected values andinsert into employeeterritories table
        /// Author:Monal Shah
        /// Created Date:2010/10/4
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// </summary>
        /// <param name="intId"></param>

        public void ListBoxValues(int intId)
        {
            // int intIdValue = SessionMethod.CurrentSession.EmployeeID;//fetch id value from session
            aryLstBoxValue = new string[LstListBox.Items.Count];
            for (int i = 0; i < LstListBox.Items.Count; i++)// in LstListBox.Items)
            {
                if (LstListBox.Items[i].Selected)
                {
                    objQuery = new StringBuilder();
                    objQuery.Append("Select ");
                    objQuery.Append("TerritoryID ");
                    objQuery.Append("From ");
                    objQuery.Append("Territories ");
                    objQuery.Append("where ");
                    objQuery.Append("TerritoryDescription");
                    objQuery.Append("=");
                    objQuery.Append("'");
                    objQuery.Append(LstListBox.Items[i].Text);
                    objQuery.Append("'");

                    string         s   = objQuery.ToString();//"Select TerritoryID from Territories where TerritoryDescription ='" + LstListBox.Items[i].Text + "'";
                    SqlDataAdapter adp = new SqlDataAdapter(s, Commonlogic.GetConnectionString);
                    objDTable = new DataTable();
                    adp.Fill(objDTable);
                    //objDTable = objCl.DataTables();
                    if (objDTable.Rows.Count > 0)
                    {
                        for (int j = 0; j < objDTable.Rows.Count; j++)
                        {
                            aryLstBoxValue[i] = objDTable.Rows[j]["TerritoryID"].ToString();
                        }
                    }
                    else
                    {
                        LblErrorMessage.Text = objConstant.NoTableRecordFound;// "Datatable Does Not Contain Any Row";
                    }
                }
            }
            for (int i = 0; i < LstListBox.Items.Count; i++)
            {
                if (aryLstBoxValue[i] != null)
                {
                    sbInsertValue = new StringBuilder();
                    sbInsertValue.Append("Insert ");
                    sbInsertValue.Append("Into ");
                    sbInsertValue.Append("EmployeeTerritories ");
                    sbInsertValue.Append("values");
                    sbInsertValue.Append("(");
                    sbInsertValue.Append("'");
                    sbInsertValue.Append(intId);
                    sbInsertValue.Append("'");
                    sbInsertValue.Append(",");
                    sbInsertValue.Append("'");
                    sbInsertValue.Append(aryLstBoxValue[i]);
                    sbInsertValue.Append("'");
                    sbInsertValue.Append(")");
                    objCl.GetSqlStmt = sbInsertValue.ToString();
                    objCl.ExecuteNonQuery();
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Name:InsertEmployeebool
        /// Description:in this method fire the insert query using stringbuilder
        /// Author:Monal shah
        /// created date:2010/09/23
        /// </summary>
        /// <returns>bool</returns>
        public bool InsertEmployee()
        {
            sbInsertValue = new StringBuilder();
            sbInsertValue.Append("Insert ");
            sbInsertValue.Append("Into ");
            sbInsertValue.Append("Employees ");
            sbInsertValue.Append("values");
            sbInsertValue.Append("(");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strLName);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strFname);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strTitle);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strSalutation);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_Bdate);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_Hdate);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strAddress);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCity);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strRegion);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strPostalCode);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strCountry);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strHomePhone);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strExtension);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strNotes);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append(_strReportsTo);
            sbInsertValue.Append("'");
            sbInsertValue.Append(",");
            sbInsertValue.Append("'");
            sbInsertValue.Append("'");
            sbInsertValue.Append(")");

            objcl.GetSqlStmt = sbInsertValue.ToString();
            return(objcl.ExecuteNonQuery());//call ExecuteNonQuery method
        }