Click here to Skip to main content
15,887,289 members
Home / Discussions / C#
   

C#

 
GeneralRe: Incrementing a Progress Bar in DAL layer Pin
Wheels01223-Jul-09 8:15
Wheels01223-Jul-09 8:15 
GeneralRe: Incrementing a Progress Bar in DAL layer Pin
Abhijit Jana23-Jul-09 10:40
professionalAbhijit Jana23-Jul-09 10:40 
GeneralRe: Incrementing a Progress Bar in DAL layer Pin
Wheels01224-Jul-09 1:18
Wheels01224-Jul-09 1:18 
GeneralRe: Incrementing a Progress Bar in DAL layer Pin
PIEBALDconsult24-Jul-09 4:36
mvePIEBALDconsult24-Jul-09 4:36 
QuestionPointers to events. Pin
Douglas Kirk22-Jul-09 9:37
Douglas Kirk22-Jul-09 9:37 
AnswerRe: Pointers to events. Pin
Luc Pattyn22-Jul-09 10:28
sitebuilderLuc Pattyn22-Jul-09 10:28 
AnswerRe: Pointers to events. Pin
Gideon Engelberth22-Jul-09 12:43
Gideon Engelberth22-Jul-09 12:43 
QuestionCode for deletion from database at form level when deleting values from data gridview using check box column and a button for delete. Pin
Omar Akhtar Sheikh22-Jul-09 8:22
Omar Akhtar Sheikh22-Jul-09 8:22 
<pre>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using Dotnet67.Sales.DAL;
using Dotnet67.Sales.Items;
using Dotnet67.Sales.Persons;

using System.Data.SqlClient;


namespace Dotnet67.Sales.DAL
{
      public class DALHelper
      {
                  private readonly string CONSTRING3 = "CASHIER1";
           
            public void InsertIntoCashier(string[] str,int[] val)
            {
                  SqlConnection con = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
                  SqlCommand com = new SqlCommand(this.CONSTRING3, con);
                  com.CommandType = CommandType.StoredProcedure;
                 
                  com.Parameters.AddWithValue("@CashierID", val[0]);
                  com.Parameters.AddWithValue("@CashierName", str[0]);
                  con.Open();
                  try
                  {
                  com.ExecuteNonQuery();
                  }
                  finally
                  {
                        con.Close();
                  }
            }
   }

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Dotnet67.Sales.DAL;
using Dotnet67.CommonTypes;
using Dotnet67.WinControls;
using System.Data.Sql;
using System.Data.SqlClient;


namespace Dotnet67.Sales.WinUI
{
      public partial class ManageCashier : Form
      {
            public ManageCashier()
            {
                  InitializeComponent();
            }

            private void btnClose_Click(object sender, EventArgs e)
            {
                  this.Close();
            }

            private void ManageCashier_Load(object sender, EventArgs e)
            {
                  // TODO: This line of code loads data into the 'dotnet67DataSet8.Cashier_2' table. You can move, or remove it, as needed.
                  this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
                 

            }

            //This is the button for inserting values into grid view which is running perfect.
            private void btnInsertIntoDataBase_Click(object sender, EventArgs e)
            {
                  DALHelper dH = new DALHelper();
                  ManageCashier mc = new ManageCashier();

                  string[] str = new string[3];
                  int[] values = new int[3];
                  str[0] = txtName.Text;
                 
                  dH.InsertIntoCashier(str,values);
                                   
                  dataGridView1.Refresh();
                  dataGridView1.RefreshEdit();
                  this.cashier_2TableAdapter.Fill(this.dotnet67DataSet8.Cashier_2);
                  //dataGridView1.AllowUserToDeleteRows.ToString();
            }

      //WHAT SHOULD I WRITE HERE IN THE BODY OF THE FOLLOWING BUTTON TO DELETE SUCCESSFULLY     
            private void btnDeleteFromGridViewAndDatabase_Click(object sender, EventArgs e)
            {
                  SqlConnection conn = new SqlConnection("server=.; Database=Dotnet67;uid=sa;pwd=123;");
                  string stro ="DELETE FROM Cashier_2 WHERE CashierID='0'" ;
                  SqlCommand sqlDelete = conn.CreateCommand();
               //sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID=                                                                                                                  '@cashierIDDataGridViewTextBoxColumn'";
                  sqlDelete.CommandText = "DELETE FROM Cashier_2 WHERE CashierID= '@CashierID'";
                  conn.Open();
                 
                 
                  sqlDelete.ExecuteNonQuery();
                  conn.Close();

            }
THE FOLLOWING IS THE STORED PROCEDURE I WROTE FOR DELETING PURPOSE.

SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE   [dbo].[UET]
@CashierID nvarchar(50)


AS
BEGIN
DELETE FROM [dbo].[Cashiers]   // DELETE from Table_Name where Coloumn=''
         WHERE CashierID='@CashierID'
END
return

</pre>
Kindly if anyone could send me the code for this scenario.
I am using a data grid view which loads the data from the database table. My database table has only two attributes i.e, CashierID and CashierName. Now in my grid view placed on the form has an extra column i.e., the check box column. Now I want the user to check the rows he wants to delete and after checking the check boxes when he clicks the Delete button on the form then not only the selected values be deleted from the grid but also from the database table as well.<b></b>
AnswerRe: Code for deletion from database at form level when deleting values from data gridview using check box column and a button for delete. [modified] Pin
Blue_Boy22-Jul-09 8:50
Blue_Boy22-Jul-09 8:50 
QuestionSendKeys {Enter} clears textbox Pin
hpydir22-Jul-09 5:53
hpydir22-Jul-09 5:53 
AnswerRe: SendKeys {Enter} clears textbox Pin
Muhammad Mazhar22-Jul-09 6:12
Muhammad Mazhar22-Jul-09 6:12 
QuestionAccessing the HTML in WebBrowser difficulty Pin
Michael Potter22-Jul-09 3:41
Michael Potter22-Jul-09 3:41 
AnswerRe: Accessing the HTML in WebBrowser difficulty Pin
Muhammad Mazhar22-Jul-09 4:25
Muhammad Mazhar22-Jul-09 4:25 
AnswerRe: Accessing the HTML in WebBrowser difficulty Pin
led mike22-Jul-09 4:31
led mike22-Jul-09 4:31 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
Michael Potter22-Jul-09 5:08
Michael Potter22-Jul-09 5:08 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
led mike22-Jul-09 5:55
led mike22-Jul-09 5:55 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
Adam R Harris22-Jul-09 6:14
Adam R Harris22-Jul-09 6:14 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
Michael Potter22-Jul-09 10:01
Michael Potter22-Jul-09 10:01 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
Adam R Harris22-Jul-09 10:12
Adam R Harris22-Jul-09 10:12 
GeneralRe: Accessing the HTML in WebBrowser difficulty Pin
Michael Potter23-Jul-09 3:45
Michael Potter23-Jul-09 3:45 
AnswerRe: Accessing the HTML in WebBrowser difficulty - SOLVED [modified] Pin
Michael Potter23-Jul-09 9:23
Michael Potter23-Jul-09 9:23 
QuestionWill C# support primitive data type in Generics Pin
Gopal_Kanchana22-Jul-09 3:28
Gopal_Kanchana22-Jul-09 3:28 
AnswerRe: Will C# support primitive data type in Generics Pin
DaveyM6922-Jul-09 3:31
professionalDaveyM6922-Jul-09 3:31 
GeneralRe: Will C# support primitive data type in Generics Pin
Gopal_Kanchana22-Jul-09 3:34
Gopal_Kanchana22-Jul-09 3:34 
GeneralRe: Will C# support primitive data type in Generics Pin
DaveyM6922-Jul-09 3:44
professionalDaveyM6922-Jul-09 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.