protected void Submit_Click(object sender, EventArgs e) { if (QueryString != HF_QueryString || QueryString <= 0 && HF_QueryString <= 0) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>alert('��ѯ�ַ�������');window.location.href='projectlist.aspx';</script>"); return; } if (string.IsNullOrEmpty(txb_Code.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ı�Ų���Ϊ��"); return; } if (string.IsNullOrEmpty(txb_BooKName.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ��������Ʋ���Ϊ��"); return; } if (string.IsNullOrEmpty(txb_Editor.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ı༭����Ϊ��"); return; } if (string.IsNullOrEmpty(txb_Pub.Text)) { LabMS.Common.JShelper.JSAlert(this, "Error", "ָ����ij����粻��Ϊ��"); return; } LabMS.BLL.GuideBook GuideBook = new LabMS.BLL.GuideBook(); LabMS.Model.GuideBook Book = new LabMS.Model.GuideBook(); Book.Guide_BookName = txb_BooKName.Text; Book.Guide_BookCode = txb_Code.Text; Book.Guide_Editor = txb_Editor.Text; Book.Guide_Award = txb_Award.Text; Book.Guide_Press = txb_Pub.Text; Book.Guide_Content = txb_Content.Text; string[] DateTimeList = { "yyyy/M/d tt hh:mm:ss", "yyyy/MM/dd tt hh:mm:ss", "yyyy/MM/dd HH:mm:ss", "yyyy/M/d HH:mm:ss", "yyyy/MM/dd", "yyyy-MM-dd hh:mm:ss", "yyyy-MM-dd", "yyyy-M-d" }; DateTime StarTime = DateTime.ParseExact(txb_PubTime.Text.Trim(), DateTimeList, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AllowInnerWhite); Book.Guide_PublishTime = StarTime; Book.Guide_ProjectID = Convert.ToInt32(Request.QueryString["ID"].ToString()); if (fup_Attach.HasFile) { string savePath = HttpContext.Current.Request.MapPath(@"../Content/UpLoadFile/"); string Append = DateTime.Now.ToString("yyyyMMddhhmmss"); string FullPathFileName = savePath.Trim() + fup_Attach.FileName.Trim() + "_" + Append.Trim() + fup_Attach.FileName.Substring(fup_Attach.FileName.LastIndexOf(".")); bool save = true; int attachid = 0; if (fup_Attach.HasFile) { try { if (fup_Attach.PostedFile.ContentLength == 0) { LabMS.Common.JShelper.JSAlert(this, "�ļ��ϴ�ʧ��", "�ļ�����Ϊ��"); return; } fup_Attach.SaveAs(FullPathFileName); save = true; } catch { LabMS.Common.JShelper.JSAlert(this, "�ļ��ϴ�ʧ��", "�ļ��ϴ�ʧ��"); return; } } if (save) { LabMS.BLL.Attachment Attach = new LabMS.BLL.Attachment(); LabMS.Model.Attachment attach = new LabMS.Model.Attachment(); attach.Attach_Name = fup_Attach.FileName; attach.Attach_Address = "Content/UpLoadFile/" + fup_Attach.FileName + "_" + Append.Trim() + fup_Attach.FileName.Substring(fup_Attach.FileName.LastIndexOf(".")); attach.Attach_Type = "2"; attachid = Attach.Add(attach); if (attachid > 0) { Book.Guide_AttachID = attachid; } } } try { GuideBook.Add(Book); } catch (Exception ex) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>;alert('���ָ����ʧ�ܣ�');refreshParent();window.location.href='ProjectPreview.aspx?ID=" + Request.QueryString["ID"].Trim() + "'</script>"); return; } Page.ClientScript.RegisterClientScriptBlock(GetType(), "script", "<script type='text/javascript'>;alert('���ʵ��ָ����ɹ���');refreshParent();window.location.href='ProjectPreview.aspx?ID=" + Request.QueryString["ID"].Trim() + "'</script>"); return; }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public LabMS.Model.GuideBook GetModel(int ID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ID,Guide_BookName,Guide_Editor,Guide_Press,Guide_PublishTime,Guide_Award,Guide_ExpriName,Guide_ExpriCode,Guide_BookCode,Guide_Content,Guide_AttachID,Guide_ProjectID from GuideBook "); strSql.Append(" where ID=@ID "); SqlParameter[] parameters = { new SqlParameter("@ID", SqlDbType.Int,4)}; parameters[0].Value = ID; LabMS.Model.GuideBook model=new LabMS.Model.GuideBook(); 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.Guide_BookName=ds.Tables[0].Rows[0]["Guide_BookName"].ToString(); model.Guide_Editor=ds.Tables[0].Rows[0]["Guide_Editor"].ToString(); model.Guide_Press=ds.Tables[0].Rows[0]["Guide_Press"].ToString(); if(ds.Tables[0].Rows[0]["Guide_PublishTime"].ToString()!="") { model.Guide_PublishTime=DateTime.Parse(ds.Tables[0].Rows[0]["Guide_PublishTime"].ToString()); } model.Guide_Award=ds.Tables[0].Rows[0]["Guide_Award"].ToString(); model.Guide_ExpriName=ds.Tables[0].Rows[0]["Guide_ExpriName"].ToString(); model.Guide_ExpriCode=ds.Tables[0].Rows[0]["Guide_ExpriCode"].ToString(); model.Guide_BookCode=ds.Tables[0].Rows[0]["Guide_BookCode"].ToString(); model.Guide_Content=ds.Tables[0].Rows[0]["Guide_Content"].ToString(); if(ds.Tables[0].Rows[0]["Guide_AttachID"].ToString()!="") { model.Guide_AttachID=int.Parse(ds.Tables[0].Rows[0]["Guide_AttachID"].ToString()); } if(ds.Tables[0].Rows[0]["Guide_ProjectID"].ToString()!="") { model.Guide_ProjectID=int.Parse(ds.Tables[0].Rows[0]["Guide_ProjectID"].ToString()); } return model; } else { return null; } }