2012-02-15 65 views
-1

你好我在哪里经理将工作分派给从电网员工web应用干活..如何从数据库中匹配ID后获取数据?

我有数据库表这样

 ManagerTable 
     Customerid 
     name 
     and some other columns 
    EmployeeTable 
    empid 
     employeeName 
    Worktable 
     CustomerID 
     EmpID 

数据库:

Table 1            Table 2 
CustomerID | CustomerName|CustomerAddress   EmpID |EmpName 
---------           ------------------- 
1 | One |--|--         1 | EmployeeName 
2 | Two           2 | EmployeeName 
3 | Three 

      Table 3 
      Tb1 | Tb2 
      --------- 
//   1 | 1 
//   1 | 2 

当过经理受让人复选框到partcualr雇员与像(CustomerID,EmployeeID)的唯一id应存储在工作表中的按钮单击,我必须检索工作表中的数据使用存储在表中的IDS并显示在网格

时曾经与他的ID的职员登录它应该在网格检查并获取数据assigen他所有的员工都有同样的网页

任何一个可以帮助我querys和代码将是最有益的。 ..

+0

我不是歌厅任何知道从哪里开始... – 2012-02-15 08:18:52

+1

那我建议,你应该先尝试网络编程和数据库SQL的一些教程。 http://www.asp.net/get-started – 2012-02-15 08:22:58

回答

1

我有同样的问题,你的我h你在网格中使用模板...给checkBox一些ID ...例如我在我的例子中给出了“Chkselect”ID复选框.. .i dnt你怎么给我的表二...但在我的例子绑定表二下拉,然后在按钮上单击每一件事情运行...

  Aspx 

      <obout:Column DataField="CUSTOMER_LOAN_NO" HeaderText="CUSTOMER_LOAN_NO" ReadOnly="true"> 
     <%-- <TemplateSettings RowEditTemplateControlId="txtCustmLn" RowEditTemplateControlPropertyName="value"/> --%>  
     <TemplateSettings TemplateId="ChkSelect1" />  
     </obout:Column> 

<obout:GridTemplate ID="ChkSelect1" runat="server" > 
     <Template> 
     <obout:OboutCheckBox runat="server" ID="Chkselect" ToolTip="<%# Container.Value %>" ></obout:OboutCheckBox> 
     </Template> 
     </obout:GridTemplate> 


    Aspx page behind code 


      void grid1_RowDataBound(object sender, GridRowEventArgs e) 
{ 
    if (e.Row.RowType == GridRowType.DataRow && GrdCustomerData.RowsInViewState.Count > 0) 
    { 
     GridDataControlFieldCell cell = e.Row.Cells[0] as GridDataControlFieldCell; 
     CheckBox chk = cell.FindControl("Chkselect") as CheckBox; 

     GridDataControlFieldCell cellInViewState = GrdCustomerData.RowsInViewState[e.Row.RowIndex].Cells[0] as GridDataControlFieldCell; 
     CheckBox chkInViewState = cellInViewState.FindControl("Chkselect") as CheckBox; 

     if (cell.Value == chkInViewState.ToolTip) 
     { 
      chk.Checked = chkInViewState.Checked; 
     } 
    } 
} 

protected void BtnAssignWork_Click(object sender, EventArgs e) 
{ 
    string LoanIds = ""; 

    for (int i = 0; i < GrdCustomerData.RowsInViewState.Count; i++) 
    { 
     GridDataControlFieldCell cell = GrdCustomerData.RowsInViewState[i].Cells[0] as GridDataControlFieldCell; 
     CheckBox chk = cell.FindControl("Chkselect") as CheckBox; 

     if (chk.Checked == true) 
     { 
      if (!string.IsNullOrEmpty(LoanIds)) 
       LoanIds += ""; 

      LoanIds = chk.ToolTip; 
        SqlConnection myconn = new SqlConnection(connstring); 
        SqlCommand mycomm = new SqlCommand("SP_AssignedWork", myconn); 
        myconn.Open(); 
        mycomm.CommandType = CommandType.StoredProcedure; 
        mycomm.Parameters.Add("@LoanID", SqlDbType.VarChar).Value = LoanIds; 
        mycomm.Parameters.Add("@EmpID", SqlDbType.VarChar).Value = DDLSelectEmployee.SelectedValue; 
        mycomm.ExecuteNonQuery(); 
        myconn.Close(); 
       } 
      } 


     } 
    } 

我希望这有助于......