protected void gvTeam_RowUpdating(object sender, GridViewUpdateEventArgs e) { HtmlInputHidden key = (HtmlInputHidden)gvTeam.Rows[e.RowIndex].Cells[0].FindControl("teamid"); string sID = key.Value; string sShift = ((DropDownList)(gvTeam.Rows[e.RowIndex].Cells[1].FindControl("ddlShift"))).SelectedValue; string sPerson = ((DropDownList)(gvTeam.Rows[e.RowIndex].Cells[2].FindControl("ddlPerson"))).SelectedValue; //string sPosition = ((DropDownList)(gvTeam.Rows[e.RowIndex].Cells[3].FindControl("ddlPosition"))).SelectedValue; string sTeamPerson = ((DropDownList)(gvTeam.Rows[e.RowIndex].Cells[4].FindControl("ddlTeamPerson"))).SelectedValue; string sNote = ((TextBox)(gvTeam.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim(); //更新 KPI_TeamEntity ote = new KPI_TeamEntity(); ote.TeamID = sID; ote.ShiftID = sShift; ote.PersonID = sPerson; ote.PositionID = KPI_PersonDal.GetPositionID(sPerson); //防止乱选sPosition; ote.TeamPersonID = sTeamPerson; ote.TeamNote = sNote; ote.TeamModifyTime = DateTime.Now.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"); if (KPI_TeamDal.Update(ote)) { MessageBox.popupClientMessage(this.Page, "编辑成功!", "call();"); } else { MessageBox.popupClientMessage(this.Page, "编辑错误!", "call();"); } gvTeam.EditIndex = -1; BindTeam(); }
protected bool ImportFromExcelToCreate(DataSet ds) { try { System.Data.DataTable dt = ds.Tables[0]; int nAll = dt.Rows.Count; int nCreate = 0; int nExist = 0; foreach (System.Data.DataRow dr in dt.Rows) { if (dr["SelectX"].ToString().ToLower() == "x") { //string PersonCode = dr["PersonCode"].ToString().Trim(); ////判断是否存在 //if (KPI_PersonDal.PersonCodeExists(PersonCode, "")) //{ // //MessageBox.popupClientMessage(this.Page, " 该机组的输出标签已存在!", "call();"); // nExist += 1; // continue; //} //main tag string keyid = PageControl.GetGuid(); KPI_TeamEntity mEntity = new KPI_TeamEntity(); mEntity.TeamID = keyid; mEntity.PlantID = KPI_PlantDal.GetPlantID(dr["PlantName"].ToString().Trim()); mEntity.ShiftID = KPI_ShiftDal.GetShiftID(dr["ShiftName"].ToString().Trim()); mEntity.PersonID = KPI_PersonDal.GetPersonID(dr["PersonCode"].ToString().Trim()); mEntity.PositionID = KPI_PersonDal.GetPositionID(mEntity.PersonID); //PersonName,无多大意义 mEntity.PositionID = KPI_PositionDal.GetPositionID(dr["PositionName"].ToString().Trim()); mEntity.TeamNote = dr["TeamNote"].ToString().Trim(); KPI_TeamDal.Insert(mEntity); nCreate += 1; } } string strInfor = "标签点总数为:{0}个, 创建成功:{1}个,已存在标签点: {2}个。"; strInfor = string.Format(strInfor, nAll, nCreate, nExist); MessageBox.popupClientMessage(this.Page, strInfor, "call();"); return(true); } catch (Exception ee) { // MessageBox.popupClientMessage(this.Page, ee.Message, "call();"); return(false); } }
/// <summary> /// 编辑时,岗位随着人变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ddlPerson_SelectedIndexChanged(object sender, EventArgs e) { DropDownList DDPerson = (DropDownList)sender; //获取现在的事件触发者:人的DropDownList GridViewRow gvr = (GridViewRow)DDPerson.NamingContainer; //人与岗位同属于在一个NamingContainer下 DropDownList DDPosition = (DropDownList)gvr.FindControl("ddlPosition"); //找到岗位的DropDownList string strperson = DDPerson.SelectedValue; string strpositionid = KPI_PersonDal.GetPositionID(strperson); DDPosition.SelectedValue = strpositionid; //DDCun.DataSource = getCommon_cun(DDXiang.SelectedValue).Tables[0].DefaultView;//这个函数是我自定义的,通过乡的编辑取得与之对应的村的数据集 //DDCun.DataTextField = "村名"; //DDCun.DataValueField = "编号"; //DDCun.DataBind(); }