Click here to Skip to main content
15,914,481 members
Home / Discussions / C#
   

C#

 
GeneralRe: About Keyword in .NET Pin
OriginalGriff22-May-10 0:09
mveOriginalGriff22-May-10 0:09 
GeneralRe: About Keyword in .NET Pin
harold aptroot22-May-10 0:24
harold aptroot22-May-10 0:24 
GeneralRe: About Keyword in .NET Pin
OriginalGriff22-May-10 0:35
mveOriginalGriff22-May-10 0:35 
GeneralRe: About Keyword in .NET Pin
Isaac Gordon22-May-10 0:55
Isaac Gordon22-May-10 0:55 
GeneralRe: About Keyword in .NET Pin
Pete O'Hanlon22-May-10 2:10
mvePete O'Hanlon22-May-10 2:10 
GeneralRe: About Keyword in .NET Pin
OriginalGriff22-May-10 2:24
mveOriginalGriff22-May-10 2:24 
AnswerRe: About Keyword in .NET Pin
Abhinav S22-May-10 0:28
Abhinav S22-May-10 0:28 
QuestionInserting multiple IDs in Items table but the same ID should go into MasterRequest table just once. Pin
Omar Akhtar 200921-May-10 20:51
Omar Akhtar 200921-May-10 20:51 
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.
AnswerRe: Inserting multiple IDs in Items table but the same ID should go into MasterRequest table just once. Pin
Mohsiul Haque21-May-10 22:46
Mohsiul Haque21-May-10 22:46 
GeneralRe: Inserting multiple IDs in Items table but the same ID should go into MasterRequest table just once. Pin
Omar Akhtar 200922-May-10 1:57
Omar Akhtar 200922-May-10 1:57 
GeneralIt Works! PinPopular
Roger Wright21-May-10 18:33
professionalRoger Wright21-May-10 18:33 
GeneralRe: It Works! Pin
Luc Pattyn21-May-10 22:36
sitebuilderLuc Pattyn21-May-10 22:36 
GeneralRe: It Works! Pin
Roger Wright22-May-10 4:20
professionalRoger Wright22-May-10 4:20 
GeneralRe: It Works! Pin
Luc Pattyn22-May-10 4:30
sitebuilderLuc Pattyn22-May-10 4:30 
GeneralRe: It Works! Pin
DaveyM6921-May-10 22:46
professionalDaveyM6921-May-10 22:46 
GeneralRe: It Works! Pin
Roger Wright22-May-10 4:23
professionalRoger Wright22-May-10 4:23 
GeneralRe: It Works! Pin
Roger Wright27-May-10 16:55
professionalRoger Wright27-May-10 16:55 
GeneralRe: It Works! Pin
DaveyM6928-May-10 8:47
professionalDaveyM6928-May-10 8:47 
GeneralRe: It Works! Pin
Roger Wright28-May-10 15:45
professionalRoger Wright28-May-10 15:45 
GeneralRe: It Works! Pin
Mohsiul Haque21-May-10 22:52
Mohsiul Haque21-May-10 22:52 
GeneralRe: It Works! Pin
Ravi Bhavnani22-May-10 6:05
professionalRavi Bhavnani22-May-10 6:05 
GeneralRe: It Works! Pin
PIEBALDconsult22-May-10 8:18
mvePIEBALDconsult22-May-10 8:18 
QuestionC # Pin
Make Up Forever21-May-10 14:27
Make Up Forever21-May-10 14:27 
AnswerRe: C # Pin
Dr.Walt Fair, PE21-May-10 14:55
professionalDr.Walt Fair, PE21-May-10 14:55 
GeneralRe: C # Pin
Make Up Forever21-May-10 15:11
Make Up Forever21-May-10 15:11 

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.