Click here to Skip to main content
15,908,906 members
Home / Discussions / C#
   

C#

 
AnswerRe: Client - Server over Internet C# Pin
harold aptroot22-May-10 5:58
harold aptroot22-May-10 5:58 
GeneralRe: Client - Server over Internet C# Pin
Member 431105722-May-10 8:27
Member 431105722-May-10 8:27 
AnswerRe: Client - Server over Internet C# Pin
Member 431105723-May-10 1:39
Member 431105723-May-10 1:39 
QuestionSetup app, with single progress dialog. Pin
David Hovey22-May-10 4:34
David Hovey22-May-10 4:34 
AnswerRe: Setup app, with single progress dialog. Pin
Abhinav S22-May-10 4:56
Abhinav S22-May-10 4:56 
AnswerRe: Setup app, with single progress dialog. Pin
DaveyM6922-May-10 5:06
professionalDaveyM6922-May-10 5:06 
AnswerRe: Setup app, with single progress dialog. Pin
Not Active22-May-10 5:34
mentorNot Active22-May-10 5:34 
QuestionInserting multiple IDs in Items table but the same ID should go into MasterRequest table just once. Pin
Omar Akhtar 200922-May-10 3:01
Omar Akhtar 200922-May-10 3:01 
public void InsertPlannedMaterialMasterRequest(int id, string requestDocument, string requestDescription, string requestType, string hodApproval, int companyCode, string hodRemarks, string det_Description, string name, int qty, string code)
    {
        string query = "INSERT INTO MasterRequest (ID,Req_Document,Req_Description,ReqType,HODApproval,CompanyCode,HODRemarks) VALUES (@ID,@Req_Document,@Req_Description,@ReqType,@HODApproval,@CompanyCode,@HODRemarks)";
        
        SqlConnection con = new SqlConnection(constr);
        SqlCommand com = new SqlCommand(query, con);
        com.Parameters.Add("@ID", SqlDbType.Int).Value = id;
        com.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
        com.Parameters.Add("@Req_Description", SqlDbType.NVarChar).Value = requestDescription;
        com.Parameters.Add("@ReqType", SqlDbType.NVarChar).Value = requestType;
        com.Parameters.Add("@HODApproval", SqlDbType.NVarChar).Value = hodApproval;
        com.Parameters.Add("@CompanyCode", SqlDbType.Int).Value = companyCode;
        com.Parameters.Add("@HODRemarks", SqlDbType.NVarChar).Value = hodRemarks;

        con.Open();
        com.ExecuteNonQuery();
        con.Close();


        string query2 = "INSERT INTO DetailRequest (ID,Req_Document,Description,Approval) VALUES (@ID,@Req_Document,@Description,@Approval)";
        SqlConnection con2 = new SqlConnection(constr);
        SqlCommand com2 = new SqlCommand(query2, con2);
        com2.Parameters.Add("@ID", SqlDbType.Int).Value = id;
        com2.Parameters.Add("@Req_Document", SqlDbType.NVarChar).Value = requestDocument;
        com2.Parameters.Add("@Description", SqlDbType.NVarChar).Value = det_Description;
        //com2.Parameters.Add("@Quantity", SqlDbType.Int).Value = qty;
        //com2.Parameters.Add("@UOM", SqlDbType.NVarChar).Value = unitOfMeasure;
        com2.Parameters.Add("@Approval", SqlDbType.NVarChar).Value = hodApproval;

        con2.Open();
        com2.ExecuteNonQuery();
        con2.Close();

        string query3 = "INSERT INTO ITEMS (ID,Code,Name,Quantity) VALUES (@ID,@Code,@Name,@Quantity)";
        SqlConnection con3 = new SqlConnection(constr);
        SqlCommand com3 = new SqlCommand(query3, con3);
        com3.Parameters.Add("@ID", SqlDbType.Int).Value = id;
        com3.Parameters.Add("@Code", SqlDbType.NVarChar).Value = code;
        com3.Parameters.Add("@Name", SqlDbType.NVarChar).Value = name;
        com3.Parameters.Add("@Quantity", SqlDbType.Int).Value = qty;

        con3.Open();
        com3.ExecuteNonQuery();
        con3.Close();


    }

//Now following is the code I am using in my PlannedmterialRequest.aspx.cs

protected void Button1_Click(object sender, EventArgs e)
    {
        MasterRequest_DAL helper = new MasterRequest_DAL();

        PlannedMaterialRequest pnd = new PlannedMaterialRequest();
        ItemsHandling itm = new ItemsHandling();

        string[] labelName = new string[100];
        string[] coder = new string[100];
        string[] quantity = new string[100];

        
        if (TextBox6.Text != "0")//if quantity entered into Capacitor textBox
        {
            labelName[1] = itm.Code(0).ToString();
            labelName[2] = TextBox6.Text;
            helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label8.Text, Convert.ToInt32(TextBox6.Text), labelName[1]);

          
        }

        if (TextBox12.Text != "0")//if quantity entered into Wires textBox
        {
            //labelName(0) needs to be commented
            //labelName[0] = pnd.Label8.Text.ToString();
            labelName[1] = itm.Code(1).ToString();
            labelName[2] = TextBox12.Text;
            helper.InsertPlannedMaterialMasterRequest(Convert.ToInt32(TextBox1.Text), TextBox2.Text, TextBox4.Text, DropDownList6.SelectedValue, DropDownList2.SelectedValue, Convert.ToInt32(TextBox11.Text), TextBox12.Text, TextBox13.Text, Label12.Text, Convert.ToInt32(TextBox8.Text), labelName[1]);



        }
}

The problem I am facing is that using the above code. The ID goes multiple times in MasterRequest table which should go only once, while the same ID must go to Items table multiple times as per the quantities being entered. I want only the ID to go into MasterRequest table just once not multiple times.
Questionxml to gridview Pin
Tomlor198022-May-10 2:49
Tomlor198022-May-10 2:49 
AnswerRe: xml to gridview [Repost] Pin
Richard MacCutchan22-May-10 4:30
mveRichard MacCutchan22-May-10 4:30 
QuestionPass dynamic datagridview value to textbox Pin
asdf2321122-May-10 1:24
asdf2321122-May-10 1:24 
QuestionCode Quality Check Pin
Chiman122-May-10 1:06
Chiman122-May-10 1:06 
AnswerRe: Code Quality Check Pin
Abhinav S22-May-10 1:13
Abhinav S22-May-10 1:13 
AnswerRe: Code Quality Check Pin
Łukasz Nowakowski22-May-10 1:35
Łukasz Nowakowski22-May-10 1:35 
GeneralRe: Code Quality Check Pin
Khaniya22-May-10 2:29
professionalKhaniya22-May-10 2:29 
QuestionWindows Forms inheritance problem Pin
Łukasz Nowakowski22-May-10 0:02
Łukasz Nowakowski22-May-10 0:02 
AnswerRe: Windows Forms inheritance problem Pin
Rob Smiley22-May-10 1:23
Rob Smiley22-May-10 1:23 
GeneralRe: Windows Forms inheritance problem Pin
Łukasz Nowakowski22-May-10 1:26
Łukasz Nowakowski22-May-10 1:26 
Questionclear history in browser Pin
Rajeshwar Code- Developer21-May-10 23:21
Rajeshwar Code- Developer21-May-10 23:21 
AnswerRe: clear history in browser Pin
Abhinav S22-May-10 0:26
Abhinav S22-May-10 0:26 
QuestionAbout Keyword in .NET Pin
Isaac Gordon21-May-10 22:12
Isaac Gordon21-May-10 22:12 
AnswerRe: About Keyword in .NET Pin
DaveyM6921-May-10 22:54
professionalDaveyM6921-May-10 22:54 
AnswerRe: About Keyword in .NET Pin
OriginalGriff21-May-10 23:07
mveOriginalGriff21-May-10 23:07 
GeneralRe: About Keyword in .NET Pin
Isaac Gordon21-May-10 23:21
Isaac Gordon21-May-10 23:21 
GeneralRe: About Keyword in .NET Pin
Pete O'Hanlon21-May-10 23:58
mvePete O'Hanlon21-May-10 23:58 

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.