protected void Submit_Click(object sender, EventArgs e) { LabMS.BLL.TeachingReform Reform = new LabMS.BLL.TeachingReform(); LabMS.Model.TeachingReform ReformItem = new LabMS.Model.TeachingReform(); ReformItem.Teach_Address = tb_Addres.Text; ReformItem.Teach_InCharge = tb_InCharge.Text; ReformItem.Teach_Mail = tb_Email.Text; ReformItem.Teach_ProjectName = tb_ProjectName.Text; ReformItem.Teach_UnitName = tb_UnitName.Text; ReformItem.Teach_UnitType = rbl_UnitType.SelectedValue; ReformItem.Teach_Phone = tb_Phone.Text; ReformItem.Teach_Time = DateTime.Now; ReformItem.Teach_DocType = ddl_ProjectType.SelectedValue.Trim(); string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + Append.Trim()+"_" + fp_Attach.FileName.Trim(); int attachID = 0; bool save = true; if (fp_Attach.HasFile) { try { fp_Attach.SaveAs(FullPathFileName); } catch { save = false; throw new Exception("File Save Error"); } } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fp_Attach.FileName; attach.Attach_Address = FullPathFileName; attachID = Attach.Add(attach); } if(attachID!=0) { ReformItem.Teach_Attachment=attachID; } Reform.Add(ReformItem); Response.Redirect(@"\ProjectApp\TeachingReformList.aspx"); }
protected void Submit_Click(object sender, EventArgs e) { LabMS.BLL.TeachingReform Reform = new LabMS.BLL.TeachingReform(); LabMS.Model.TeachingReform model = new LabMS.Model.TeachingReform(); model = Reform.GetModel(Convert.ToInt32(QueryString)); model.Teach_ProjectName = tb_ProjectName.Text; model.Teach_Address = tb_Addres.Text; model.Teach_InCharge = tb_InCharge.Text; model.Teach_Mail = tb_Email.Text; model.Teach_ProjectName = tb_ProjectName.Text; model.Teach_UnitName = tb_UnitName.Text; model.Teach_UnitType = rbl_UnitType.SelectedValue; model.Teach_Phone = tb_Phone.Text; model.Teach_Time = DateTime.Now; model.Teach_DocType = ddl_ProjectType.SelectedValue.Trim(); Reform.Update(model); Response.Redirect(@"\ProjectApp\TeachingReformList.aspx"); }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.TeachingReform GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,Teach_DocType,Teach_ProjectName,Teach_InCharge,Teach_UnitName,Teach_UnitType,Teach_Address,Teach_Phone,Teach_Mail,Teach_Time,Teach_Attachment from TeachingReform "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.TeachingReform model=new LabMS.Model.TeachingReform(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["ID"].ToString()!="") { model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()); } model.Teach_DocType=ds.Tables[0].Rows[0]["Teach_DocType"].ToString(); model.Teach_ProjectName=ds.Tables[0].Rows[0]["Teach_ProjectName"].ToString(); model.Teach_InCharge=ds.Tables[0].Rows[0]["Teach_InCharge"].ToString(); model.Teach_UnitName=ds.Tables[0].Rows[0]["Teach_UnitName"].ToString(); model.Teach_UnitType=ds.Tables[0].Rows[0]["Teach_UnitType"].ToString(); model.Teach_Address=ds.Tables[0].Rows[0]["Teach_Address"].ToString(); model.Teach_Phone=ds.Tables[0].Rows[0]["Teach_Phone"].ToString(); model.Teach_Mail=ds.Tables[0].Rows[0]["Teach_Mail"].ToString(); if(ds.Tables[0].Rows[0]["Teach_Time"].ToString()!="") { model.Teach_Time=DateTime.Parse(ds.Tables[0].Rows[0]["Teach_Time"].ToString()); } if(ds.Tables[0].Rows[0]["Teach_Attachment"].ToString()!="") { model.Teach_Attachment=int.Parse(ds.Tables[0].Rows[0]["Teach_Attachment"].ToString()); } return model; } else { return null; } }