码迷,mamicode.com
首页 > 其他好文 > 详细

ERP联系记录管理(十七)

时间:2016-10-30 01:07:01      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:ie8   adsi   lcx   hack   联系人   waf   hdu   cte   create   

联系记录管理修改页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ContactRecordUpdate.aspx.cs"
    Inherits="BioErpWeb.CRMSystem.ContactRecordUpdate" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />
    <script src="../JS/CustomerName.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.validate.js" type="text/javascript"></script>
    <script src="../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>

    <style type="text/css">
        .style1
        {
            height: 22px;
        }
    </style>

    <script type="text/javascript">
        $().ready(function () {
            $("#form1").validate();
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
        <table class="maintable">
            <tr>
                <td colspan="4" class="titlebar">
                    客户联系记录编辑
                </td>
            </tr>
            <tr>
                <td class="style1">
                    客户编号
                </td>
                <td class="style1">
                    <asp:TextBox ID="txtCustomerID" CssClass="required number" runat="server" OnTextChanged="txtCustomerID_TextChanged"></asp:TextBox>
                    <asp:Button  ID="Button1" runat="server" Text="选择客户" OnClientClick="showCustomerDialog()" />
                </td>
                <td class="style1">
                    客户联系人
                </td>
                <td class="style1">
                    <asp:DropDownList ID="ddlLinkMan" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    联系时间
                </td>
                <td>
                  <asp:TextBox ID="txtContractTime" CssClass="required" runat="server"></asp:TextBox>
                    <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtContractTime" Format="yyyy-MM-dd" runat="server">
                    </cc1:CalendarExtender>
                </td>
                <td>
                    记录时间
                </td>
                <td>
                   <asp:Label ID="lbNoteTime" runat="server" Text="Label"></asp:Label>
                </td>
            </tr>
            <tr>
                <td>
                    联系类别
                </td>
                <td>
                    <asp:DropDownList ID="ddlType" runat="server">
                        <asp:ListItem>人工</asp:ListItem>
                        <asp:ListItem>自能</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td>
                    联系方式
                </td>
                <td>
                    <asp:DropDownList ID="ddlMethod" runat="server">
                        <asp:ListItem>电话</asp:ListItem>
                        <asp:ListItem>短信</asp:ListItem>
                        <asp:ListItem>Email</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td>
                    联系内容
                </td>
                <td colspan="3">
                    <asp:TextBox ID="txtContent" Width="552px" Height="101px" CssClass="required" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td>
                    是否删除</td>
                <td colspan="3">
                    <asp:CheckBox ID="cbDetele" runat="server"/>
                </td>
            </tr>
            <tr>
                <td colspan="4" class="bottomtd">
                    <asp:Button ID="btnSubmit" runat="server" Text="客户联系记录编辑" OnClick="btnSubmit_Click" />
                    <asp:Button ID="btnReturn" runat="server" Text="返回列表" OnClick="btnReturn_Click" />
                </td>
            </tr>
        </table>
        <br />
    </div>
    </form>
</body>
</html>

后台的代码:

  public partial class ContactRecordUpdate : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            this.lbNoteTime.Text = DateTime.Now.ToShortDateString();
            Session["Userid"] = "29";
            if (Session["Userid"] == null)
            {
                Response.Redirect("~/Web/Desk.aspx");

            }
            if (!IsPostBack)
            {
                pageinfobind();
            }
        
        }
        protected void pageinfobind()
        {
           
            if (Request.QueryString["ID"] != null)
            {
                string recordid = Request.QueryString["ID"].ToString();
                BioCrmContactRecordBLL rbll = new BioCrmContactRecordBLL();
                BioCrmContactRecord record = new BioCrmContactRecord();
                record=rbll.GetContactRecordByID(int.Parse(recordid));
                this.txtCustomerID.Text = record.CustomerID.ToString();
                //绑定联系人,根据联系人编号
                ddlLinkManBind(" LinkmanID=" + record.LinkmanID.ToString());
                txtContractTime.Text = record.ContactTime.ToString();
                lbNoteTime.Text = record.NoteTime.ToString();
                ddlType.SelectedValue = record.Type;
                ddlMethod.SelectedValue = record.Method;
                txtContent.Text = record.Note;
                cbDetele.Checked =Convert.ToBoolean(record.DeleteState);
            }
        }
        /// <summary>
        /// 根据条件绑定联系人信息
        /// </summary>
        /// <param name="condition"></param>
        private void ddlLinkManBind(string condition)
        {
            ddlLinkMan.DataSource = SqlComm.GetDataByCondition("BioCrmLinkmanInfo", "LinkmanID,LinkmanName", condition);
            ddlLinkMan.DataTextField = "LinkmanName";
            ddlLinkMan.DataValueField = "LinkmanID";
            ddlLinkMan.DataBind();
        }


        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (Request.QueryString["ID"] != null)
            {
                BioCrmContactRecord record = new BioCrmContactRecord();
                BioCrmContactRecordBLL rbll = new BioCrmContactRecordBLL();

                record.NoteID =int.Parse( Request.QueryString["ID"].ToString());
                record.CustomerID = int.Parse(this.txtCustomerID.Text.Trim());
                if (ddlLinkMan.SelectedValue == null || ddlLinkMan.SelectedValue == "0")
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(‘此客户没有联系人,请先添加联系人‘);", true);
                    return;
                }
                record.LinkmanID = int.Parse(ddlLinkMan.SelectedValue.ToString());
                record.ContactTime = Convert.ToDateTime(this.txtContractTime.Text);
                record.NoteTime = Convert.ToDateTime(this.lbNoteTime.Text.Trim());
                record.Type = this.ddlType.SelectedValue.ToString();
                record.Method = this.ddlMethod.SelectedValue;
                record.Note = this.txtContent.Text;
                record.UserID = int.Parse(Session["Userid"].ToString());
                record.DeleteState = cbDetele.Checked;
                if (rbll.BioCrmContactRecord_Update(record) != 0)
                {
                    Response.Redirect("RecordListShow.aspx");
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "test", "alert(‘修改失败‘);", true);
                }
            }


        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Server.Transfer("RecordListShow.aspx");
        }

        protected void txtCustomerID_TextChanged(object sender, EventArgs e)
        {
         if(txtCustomerID.Text.Trim()!="" && txtCustomerID.Text.Trim().Length!=0&&txtCustomerID.Text.Trim()!="请选择")
            {
                string id=this.txtCustomerID.Text;
                System.Data.DataTable dt = SqlComm.GetDataByCondition("BioCrmLinkmanInfo", "LinkmanID,LinkmanName", "CustomerID=" + id).Tables[0];
                if (dt.Rows.Count > 0)
                {
                    this.ddlLinkMan.DataSource = dt;
                    this.ddlLinkMan.DataTextField = "LinkmanName";
                    this.ddlLinkMan.DataValueField = "LinkmanID";
                    this.ddlLinkMan.DataBind();
                }
                else
                {
                    this.ddlLinkMan.Items.Clear();
                    this.ddlLinkMan.Items.Add(new ListItem("--请选择--", "0"));
                }
            }
        }
    }

 查询的页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RecordListShow.aspx.cs" Inherits="BioErpWeb.CRMSystem.RecordListShow" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

<%@ Register src="../UserControl/CRMMenuBar.ascx" tagname="CRMMenuBar" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/AspNetPagerStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    td{ text-align:center;}
    .tdsearch{ line-height:30px;}
    .menubar{ background:url(../Web/images/block_hd_bg.png); height:25px; width:100%;}
    .menubar ul{ margin:0px; padding:0px; list-style:none;}
    .menubar ul li{ display:inline; line-height:25px;}
    .menubar ul li a{display:inline-block;  text-align:center; width:100px; color:#0066CC; text-decoration:none;}

    </style>
    <script src="../JS/CustomerName.js" type="text/javascript"></script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
 
        <uc1:CRMMenuBar ID="CRMMenuBar1" runat="server" />
 
    </div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
    <div>
         <table class="maintable" style=" width:900px;">
             <tr>
                 <td colspan="5" class="titlebar">
                     <span>客户联系记录管理</span>
                 </td>
             </tr>
             <tr>
                 <td class="tdsearch">
                       <asp:Label ID="Label2" runat="server" Text="客户名:"></asp:Label>
                      <asp:TextBox ID="txtCustomerID" runat="server"></asp:TextBox>
                     <input ID="Button1" value="选择客户" type="button" Width="60px"  onclick="showCustomerDialog()" />
                 </td>
                 <td class="tdsearch">
                 <asp:Label ID="Label1" runat="server" Text="联系人姓名:"></asp:Label>
                     <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                   
              </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label3" runat="server" Text="联系时间"></asp:Label>
                     <asp:TextBox ID="txtContactTime" runat="server"></asp:TextBox>
                     <cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="txtContactTime" Format="yyyy-MM-dd" runat="server">
                     </cc1:CalendarExtender>

                 </td>
                 
                 <td class="tdsearch">
                     <asp:ImageButton ID="imgbutnSearch" Width="60" Height="22" runat="server" 
                         ImageUrl="~/Web/images/Btnsearch.gif" onclick="imgbutnSearch_Click" /> 
                     <asp:ImageButton ID="imgbtnNew" runat="server"  Width="60" Height="22" 
                         ImageUrl="~/Web/images/btnadd.gif" onclick="imgbtnNew_Click"/>
                 </td>
             </tr>
             <tr>
                 <td colspan="5" class="bottomtd">
                     <asp:GridView ID="GridView1" Width="100%"  runat="server"  AutoGenerateColumns="False" DataKeyNames="NoteID">
                         <Columns>
                             <asp:TemplateField HeaderText="记录编号" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label4" runat="server" Text=‘<%# Eval("NoteID") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="联系人姓名" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label5" runat="server" Text=‘<%# Eval("LinkmanName") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <ItemStyle Width="120px" HorizontalAlign="Center" />
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="所属客户(公司)" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label6" runat="server" Text=‘<%# Eval("CustomerName") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="联系时间" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label7" runat="server" Text=‘<%# Convert.ToDateTime(Eval("ContactTime")).ToString("yyyy-MM-dd") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="联系方式" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label9" runat="server" Text=‘<%# Eval("Method") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="操作员工" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label10" runat="server" Text=‘<%#Eval("UserName") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="联系内容" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label10" runat="server" Text=‘<%#Eval("Note").ToString().Length>5?Eval("Note").ToString().Substring(0,5)+"…":Eval("Note").ToString()  %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                        

                                                 
                             <asp:HyperLinkField DataNavigateUrlFields="NoteID" 
                                 DataNavigateUrlFormatString="ContactRecordUpdate.aspx?ID={0}" HeaderText="操作" 
                                 Text="查看并修改">
                             <HeaderStyle HorizontalAlign="Center" />
                             <ItemStyle HorizontalAlign="Center" />
                             </asp:HyperLinkField>
                         </Columns>
                     </asp:GridView>
                 </td>
             </tr>
             <tr>
              <td  colspan="5">
                  <webdiyer:AspNetPager ID="AspNetPager1" runat="server"   CssClass="paginator" CurrentPageButtonClass="cpb"
                      onpagechanged="AspNetPager1_PageChanged">
                  </webdiyer:AspNetPager>
                 </td>
             </tr>

     </table>

    </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>
    
    </form>
</body>
</html>

 后台代码:

 public partial class RecordListShow : System.Web.UI.Page
    {
        
        public static int pageindex = 0;
        public static int pagesize = 10;
        public static string condition = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            
           if (!IsPostBack)
            {

               getallPageList();
            }
        }

   

        /// <summary>
        /// 查询所有联系人信息
        /// </summary>
        private void getallPageList()
        {
            this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_CRMContactRecordInfo", condition);
            this.AspNetPager1.PageSize = pagesize;
            this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_CRMContactRecordInfo", "*", "NoteID", condition, pageindex, pagesize);
            this.GridView1.DataBind();           
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            pageindex = this.AspNetPager1.CurrentPageIndex - 1;
            getallPageList();
        }

        protected void imgbutnSearch_Click(object sender, ImageClickEventArgs e)
        {
            pageindex = 0;
            condition = "";
            if (txtName.Text.Trim() != null && this.txtName.Text.Trim().Length != 0)
            {
                condition = condition + " and LinkmanName like ‘" + txtName.Text + "%‘";
            }

            if (this.txtCustomerID.Text.Trim() != null && this.txtCustomerID.Text.Trim().Length != 0)
            {
                condition = condition + " and CustomerID  =‘" + this.txtCustomerID.Text + "‘";
            }

            if (this.txtContactTime.Text != "")
            {
                condition = condition + " and ContactTime  =‘" + this.txtContactTime.Text + "‘";
            }

            getallPageList();
        }

        protected void btnNew_Click(object sender, EventArgs e)
        {

        }

        protected void imgbtnNew_Click(object sender, ImageClickEventArgs e)
        {
            Server.Transfer("LinkManAdd.aspx");
        }
    }

 CRM客户管理系统文档管理:

需求:

1.根据相关客户生成相关文档,此模块是用来对客户相关的文档资料进行管理。

2.涉及到的基本信息:文档主题、文件名、文档类型、文档等级、文件大小、扩展名、文件内容、上传人、上传时间、文档说明、关联客户

3.主要功能点:

1、列表显示文档信息

2、添加文档资料

3、修改文档资料

4、删除文档资料

5、查看文档资料

实现的思路:

-- Description:	添加一条文档
-- =============================================
ALTER PROCEDURE [dbo].[BioCrmCorrelationDocument_Add] 
--输出参数
    @DocumentID int output,
	@Subject nvarchar(100),
	@Name nvarchar(100),
	@Type nvarchar(100),
	@DocumentLevel nvarchar(100),
	@DocumentSize bigint,
	@ExetendName nvarchar(20),
	@Content image,
	@UserID  int,
--	@UploadTime datetime,
	@Remark nvarchar(200)
AS
BEGIN
--为on是只返回受影响的行数
	SET NOCOUNT ON;
	INSERT BioCrmCorrelationDocument
	(
		Subject,
		[Name],
		[Type],
		DocumentLevel,
		DocumentSize,
		ExetendName,
		[Content],
		UserID,	
		Remark
	)
	VALUES
	(	
		@Subject,
		@Name,
		@Type,
		@DocumentLevel,
		@DocumentSize,
		@ExetendName,
		@Content,
		@UserID,		
		@Remark
	)
--表示列的值
    SET @DocumentID=@@IDENTITY
END

 修改文档:

Description:	修改文档信息
-- =============================================
ALTER PROCEDURE [dbo].[BioCrmSPCorrelationDocument_Update] 
	(
		@DocumentID int,
		@Subject nvarchar(100),
		@Name nvarchar(100),
		@Type nvarchar(100),
		@DocumentLevel nvarchar(100),
		@DocumentSize bigint,
		@ExetendName nvarchar(20),
		@Content image,
		@UserID nvarchar(20),
		@UploadTime datetime,
		@Remark nvarchar(200)
		
	)
	AS
BEGIN
	
	SET NOCOUNT ON;
    UPDATE BioCrmCorrelationDocument
    SET
    	Subject = @Subject,
    	[Name] = @Name,
    	[Type] = @Type,
    	DocumentLevel =@DocumentLevel,
    	DocumentSize = @DocumentSize,
    	ExetendName = @ExetendName,
    	[Content] = @Content,
    	UserID = @UserID,
    	UploadTime = @UploadTime,
    	Remark = @Remark
    WHERE 
    DocumentID=@DocumentID
END

添加一条文档客户关系的信息:

ALTER PROCEDURE [dbo].[BioCrmCustomerDocument_ADD]
@CustomerID int,
@DocumentID int,
@DeleteState bit
 AS 
	INSERT INTO [BioCrmCustomerDocument](
	[CustomerID],[DocumentID],[DeleteState]
	)VALUES(
	@CustomerID,@DocumentID,@DeleteState
	)

 修改一条文档客户关系的信息:

ALTER PROCEDURE [dbo].[BioCrmCustomerDocument_Update]
@CustomerDocumentID int,
@CustomerID int,
@DocumentID int,
@DeleteState bit
 AS 
	UPDATE [BioCrmCustomerDocument] SET 
	[CustomerID] = @CustomerID,[DocumentID] = @DocumentID,[DeleteState] = @DeleteState
	WHERE CustomerDocumentID=@CustomerDocumentID 

 BLL层:

 public class BioCrmCustomerDocumentBLL
    {
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int BioCrmCustomerDocumentAdd(BioCrmCustomerDocument model)
        {
            SqlParameter[] parameters = {					
					new SqlParameter("@CustomerID", SqlDbType.Int,4),
					new SqlParameter("@DocumentID", SqlDbType.Int,4),
					new SqlParameter("@DeleteState", SqlDbType.Bit,1)};
            parameters[0].Value = model.CustomerID;
            parameters[1].Value = model.DocumentID;
            parameters[2].Value = model.DeleteState;


            return DataBaseHelper.ExcuteSqlReturnInt("BioCrmCustomerDocument_ADD", CommandType.StoredProcedure, parameters);

        }
        /// <summary>
        ///  修改一条数据
        /// </summary>
        public int BioCrmCustomerDocumentUpdate(BioCrmCustomerDocument model)
        {
            SqlParameter[] parameters = {	
				    new SqlParameter("@CustomerDocumentID",SqlDbType.Int,4),
					new SqlParameter("@CustomerID", SqlDbType.Int,4),
					new SqlParameter("@DocumentID", SqlDbType.Int,4),
					new SqlParameter("@DeleteState", SqlDbType.Bit,1)};
            parameters[0].Value = model.CustomerID;
            parameters[1].Value = model.CustomerID;
            parameters[2].Value = model.DocumentID;
            parameters[3].Value = model.DeleteState;


            return DataBaseHelper.ExcuteSqlReturnInt("BioCrmCustomerDocument_Update", CommandType.StoredProcedure, parameters);

        }
    }
}

 客户文档信息:

 public  class BioCrmCorrelationDocumentBLL
    {

      /// <summary>
      /// 添加一个文档对象,并且返回当前文档对象的编号
      /// </summary>
      /// <param name="document">document</param>
      /// <returns>int</returns>
      public int BioCrmCorrelationDocumentAdd(BioCrmCorrelationDocument document)
      {
          SqlParameter[] pars = new SqlParameter[]{
           new SqlParameter("@DocumentID",SqlDbType.Int),
           new SqlParameter("@Subject",document.Subject),
           new SqlParameter("@Name",document.Name),
           new SqlParameter("@Type",document.Type),
           new SqlParameter("@DocumentLevel",document.DocumentLevel),
           new SqlParameter("@DocumentSize",document.DocumentSize),
           new SqlParameter("@ExetendName",document.ExetendName),
           new SqlParameter("@Content",document.Content),
           new SqlParameter("@UserID",document.UserID),
           new SqlParameter("@Remark",document.Remark)
          };

          pars[0].Direction = ParameterDirection.Output;

         int count= DataBaseHelper.ExcuteSqlReturnInt("BioCrmCorrelationDocument_Add", CommandType.StoredProcedure, pars);
         if (count != 0)
         {
             return int.Parse(pars[0].Value.ToString());
         }
         else
         {
             return 0;
         }
      
      }

      /// <summary>
      /// 修改一个文档对象
      /// </summary>
      /// <param name="document">document</param>
      /// <returns>int</returns>
      public int BioCrmCorrelationDocumentUpdate(BioCrmCorrelationDocument document)
      {
          SqlParameter[] pars = new SqlParameter[]{
           new SqlParameter("@DocumentID",document.DocumentID),
           new SqlParameter("@Subject",document.Subject),
           new SqlParameter("@Name",document.Name),
           new SqlParameter("@Type",document.Type),
           new SqlParameter("@DocumentLevel",document.DocumentLevel),
           new SqlParameter("@DocumentSize",document.DocumentSize),
           new SqlParameter("@ExetendName",document.ExetendName),
           new SqlParameter("@Content",document.Content),
           new SqlParameter("@UserID",document.UserID),
           new SqlParameter("@Remark",document.Remark)
          };

         int count = DataBaseHelper.ExcuteSqlReturnInt("BioCrmSPCorrelationDocument_Update", CommandType.StoredProcedure, pars);
         return count;

      }
    }

 添加的页面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocumentAdd.aspx.cs" Inherits="BioErpWeb.CRMSystem.DocumentAdd"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />  
    <script src="../JS/CustomerName.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.validate.js" type="text/javascript"></script>
    <script src="../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#form1").validate();
        });
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <table class="maintable">
      <tr>
       <td colspan="2" class="titlebar"><span>客户文档信息上传</span></td>
      </tr>
       <tr>
           <td>主题</td><td><asp:TextBox ID="txtsubJect" runat="server" CssClass="required"></asp:TextBox></td>
       </tr>
      <tr>
            <td>
                文档等级</td>
          <td>
              <asp:DropDownList ID="ddlLevel" runat="server">
                  <asp:ListItem Selected="True">一般文件</asp:ListItem>
                  <asp:ListItem>重要文件</asp:ListItem>
                  <asp:ListItem>非常重要文件</asp:ListItem>
                  <asp:ListItem>特别重要</asp:ListItem>
              </asp:DropDownList>
          </td>
      </tr>
        <tr>
            <td>
                文档选择</td>
          <td>
              <asp:FileUpload ID="FileUpload1" runat="server" />
          </td>
      </tr>
          <tr>
            <td>
              所属客户
          </td>
          <td >
              <asp:TextBox ID="txtCustomerID" runat="server"></asp:TextBox><input type="button" value="选择客户" style=" width:100px;" onclick="showCustomerDialog()" />
          </td> 
      </tr>
          <tr>
            <td>
                说明</td>
          <td >
              <asp:TextBox ID="txtRemark" TextMode="MultiLine" Rows="5" runat="server" 
                  Width="380px"></asp:TextBox>
          </td> 
      </tr>
         <tr>
             <td colspan="2" class="bottomtd">
             
                 <asp:Button ID="btnSubmit" runat="server" Text="文档信息上传" 
                     onclick="btnSubmit_Click" />
                                  
                 <asp:Button ID="btnReturn" runat="server" Text="返回列表" onclick="btnReturn_Click" 
                     />

             </td>
         </tr>

     </table>
        <br />
    </div>
    </form>
</body>
</html>

 后台代码:

 public partial class DocumentAdd : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Userid"] = "29";
            if (!IsPostBack)
            {
               
            }
        }

       
        
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BioCrmCorrelationDocument document = new BioCrmCorrelationDocument();
            document.Subject = this.txtsubJect.Text;
            //保证文件的不重复
            document.Name =DateTime.Now.ToString("yyyyMMdd hhmmss")+ this.FileUpload1.FileName;
    
            document.UserID =int.Parse( Session["Userid"].ToString());
            document.Remark = this.txtRemark.Text;
            document.DocumentLevel = this.ddlLevel.SelectedValue;
            document.Content = this.FileUpload1.FileBytes;

            //获取文档的长度
            document.DocumentSize=this.FileUpload1.FileContent.Length;
            //文件的类型
            document.Type=this.FileUpload1.PostedFile.ContentType;
            //文件的类型
            document.ExetendName=System.IO.Path.GetExtension(this.FileUpload1.FileName);

            //物理文件上传
            string filepath = Server.MapPath(@"\Files\CRMFiles\");
            //调用共用的上传方法
            Comm.FileUpLoad(this.FileUpload1, filepath, document.Name);
            
            BioCrmCorrelationDocumentBLL documentbll = new BioCrmCorrelationDocumentBLL();
            //文档信息添加 包括文件上传(转换为二进制数组后上传)
            int documentid= documentbll.BioCrmCorrelationDocumentAdd(document);
            //文档信息添加成功
            if (documentid != 0)
            {
                BioCrmCustomerDocument customerdocument = new BioCrmCustomerDocument();
                customerdocument.CustomerID = int.Parse(this.txtCustomerID.Text);
                customerdocument.DeleteState = false;
                customerdocument.DocumentID = documentid;
                BioCrmCustomerDocumentBLL customerdocumentbll = new BioCrmCustomerDocumentBLL();
                   int count= customerdocumentbll.BioCrmCustomerDocumentAdd(customerdocument);
                   if (count == 0)
                   {
                       SqlComm.DeleteTableByCondition("BioCrmCorrelationDocument", "where DocumentID=" + documentid.ToString());
                   }
            }
        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Server.Transfer("DocumentListShow.aspx");
        }
       
    }

创建一个重载的方法:

 /// <summary>
       /// 与上面构建一个重载的方法
       /// </summary>
       /// <param name="fload"></param>
       /// <param name="path"></param>
       /// <param name="FileName"></param>
       /// <returns></returns>
       public static string FileUpLoad(FileUpload fload, string path,string FileName)
       {
           //判断指定路径是否存在此目录,如果没有则创建
           if (!System.IO.Directory.Exists(path))
           {
               System.IO.Directory.CreateDirectory(path);
           }

           int count = 0;

           string NewFileName = FileName;
           //上传文件之前判断指定路径是否已经存在此文件,如果存在,则删除
           if (System.IO.File.Exists(path + NewFileName))
           {
               System.IO.File.Delete(path + NewFileName);
           }

           try
           {

               fload.SaveAs(path + NewFileName);
           }
           catch (Exception ex)
           {
               count++;
           }

           if (count > 0)
           {
               return "false";
           }
           else
           {
               return NewFileName;
           }
       }

 查询创建一个视图:

SELECT   dbo.BioCrmCustomer.CustomerName, dbo.BioCrmCorrelationDocument.DocumentID, 
                dbo.BioCrmCorrelationDocument.Subject, dbo.BioCrmCorrelationDocument.Name, 
                dbo.BioCrmCorrelationDocument.Type, dbo.BioCrmCorrelationDocument.DocumentLevel, 
                dbo.BioCrmCorrelationDocument.DocumentSize, dbo.BioCrmCorrelationDocument.ExetendName, 
                dbo.BioCrmCorrelationDocument.[Content], dbo.BioCrmCorrelationDocument.UserID, 
                dbo.BioCrmCorrelationDocument.UploadTime, dbo.BioCrmCorrelationDocument.Remark, 
                dbo.BioCrmCustomerDocument.CustomerID, dbo.BioCrmCustomerDocument.DeleteState, 
                dbo.BioCrmCustomerDocument.CustomerDocumentID
FROM      dbo.BioCrmCustomerDocument INNER JOIN
                dbo.BioCrmCorrelationDocument ON 
                dbo.BioCrmCustomerDocument.DocumentID = dbo.BioCrmCorrelationDocument.DocumentID INNER JOIN
                dbo.BioCrmCustomer ON dbo.BioCrmCustomerDocument.CustomerID = dbo.BioCrmCustomer.CustomerID

 视图中表的关联关系:

技术分享

 

前台显示的界面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocumentListShow.aspx.cs" Inherits="BioErpWeb.CRMSystem.DocumentListShow" %>

<%@ Register assembly="AspNetPager" namespace="Wuqi.Webdiyer" tagprefix="webdiyer" %>

<%@ Register src="../UserControl/CRMMenuBar.ascx" tagname="CRMMenuBar" tagprefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/AspNetPagerStyle.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
    td{ text-align:center;}
    .tdsearch{ line-height:30px;}
    .menubar{ background:url(../Web/images/block_hd_bg.png); height:25px; width:100%;}
    .menubar ul{ margin:0px; padding:0px; list-style:none;}
    .menubar ul li{ display:inline; line-height:25px;}
    .menubar ul li a{display:inline-block;  text-align:center; width:100px; color:#0066CC; text-decoration:none;}

    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
 
        <uc1:CRMMenuBar ID="CRMMenuBar1" runat="server" />
 
    </div>
    <div>
         <table class="maintable" style=" width:900px;">
             <tr>
                 <td colspan="5" class="titlebar">
                     <span>客户文档管理</span>
                 </td>
             </tr>
             <tr>
                 <td class="tdsearch">
                     <asp:Label ID="Label1" runat="server" Text="文档主题:"></asp:Label>
                     <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                 </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label2" runat="server" Text="客户名:"></asp:Label>
                      <asp:TextBox ID="txtCName" runat="server"></asp:TextBox>
              </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label3" runat="server" Text="文件级别:"></asp:Label>
                        <asp:DropDownList ID="ddlLevel" runat="server">
                         <asp:ListItem Selected="True">--请选择--</asp:ListItem>
                        <asp:ListItem>一般文件</asp:ListItem>
                        <asp:ListItem>重要文件</asp:ListItem>
                        <asp:ListItem>非常重要文件</asp:ListItem>
                        <asp:ListItem>特别重要</asp:ListItem>
                        </asp:DropDownList>
                 </td>
                 
                 <td class="tdsearch">
                     <asp:ImageButton ID="imgbutnSearch" Width="60" Height="22" runat="server" 
                         ImageUrl="~/Web/images/Btnsearch.gif" onclick="imgbutnSearch_Click" /> 
                     <asp:ImageButton ID="imgbtnNew" runat="server"  Width="60" Height="22" 
                         ImageUrl="~/Web/images/btnadd.gif" onclick="imgbtnNew_Click"/>
                 </td>
             </tr>
             <tr>
                 <td colspan="5" class="bottomtd">
                     <asp:GridView ID="GridView1" Width="100%"  runat="server"  AutoGenerateColumns="False" DataKeyNames="DocumentID">
                         <Columns>
                             <asp:TemplateField HeaderText="文档主题" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label4" runat="server" Text=‘<%# Eval("Subject") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="文档名" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label5" runat="server" Text=‘<%# Eval("Name") %>‘></asp:Label>
                                 </ItemTemplate>
                                 
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="所属客户(公司)" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label6" runat="server" Text=‘<%# Eval("CustomerName") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="文件级别" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label7" runat="server" Text=‘<%# Eval("DocumentLevel") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="上传时间" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label9" runat="server" Text=‘<%# Eval("UploadTime") %>‘></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                       

                                                 
                             <asp:HyperLinkField DataNavigateUrlFields="DocumentID" 
                                 DataNavigateUrlFormatString="DocumentEditAndDown.aspx?ID={0}" HeaderText="操作" 
                                 Text="下载/编辑">
                             <HeaderStyle HorizontalAlign="Center" />
                             <ItemStyle HorizontalAlign="Center" />
                             </asp:HyperLinkField>
                         </Columns>
                     </asp:GridView>
                 </td>
             </tr>
             <tr>
              <td  colspan="5">
                  <webdiyer:AspNetPager ID="AspNetPager1" runat="server"   CssClass="paginator" CurrentPageButtonClass="cpb"
                      onpagechanged="AspNetPager1_PageChanged">
                  </webdiyer:AspNetPager>
                 </td>
             </tr>

     </table>

    </div>
    </form>
</body>
</html>

 后台显示和添加的代码:

  public partial class DocumentListShow : System.Web.UI.Page
    {
        
        public static int pageindex = 0;
        public static int pagesize = 10;
        public static string condition = "";

        protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack)
            {

               getallPageList();
            }
        }

   

        /// <summary>
        /// 查询所有联系人信息
        /// </summary>
        private void getallPageList()
        {
            this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_DoucmentInfo", condition);
            this.AspNetPager1.PageSize = pagesize;
            this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_DoucmentInfo", "*", "DocumentID", condition, pageindex, pagesize);
            this.GridView1.DataBind();           
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            pageindex = this.AspNetPager1.CurrentPageIndex - 1;
            getallPageList();
        }

        protected void imgbutnSearch_Click(object sender, ImageClickEventArgs e)
        {
            pageindex = 0;
            condition = "";
            if (txtName.Text.Trim() != null && this.txtName.Text.Trim().Length != 0)
            {
                condition = condition + " and Subject like ‘" + txtName.Text + "%‘";
            }

            if (this.txtCName.Text.Trim() != null && this.txtCName.Text.Trim().Length != 0)
            {
                condition = condition + " and CustomerName like ‘" + txtCName.Text + "%‘";
            }

            if (this.ddlLevel.SelectedItem.Text != "--请选择--")
            {
                condition = condition + " and DocumentLevel =‘" + this.ddlLevel.SelectedItem.Text + "‘";
            }
         

            getallPageList();

        }

        protected void imgbtnNew_Click(object sender, ImageClickEventArgs e)
        {
            Server.Transfer("LinkManAdd.aspx");
        }

    }

 下载和修改的界面:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DocumentEditAndDown.aspx.cs" Inherits="BioErpWeb.CRMSystem.DocumentEditAndDown"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Styles/ERPBaseStyle.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/CalenderStyle.css" rel="stylesheet" type="text/css" />  
    <script src="../JS/CustomerName.js" type="text/javascript"></script>
    <script src="../JS/CheckUserName.js" type="text/javascript"></script>
    <script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src="../Scripts/jquery.validate.js" type="text/javascript"></script>
    <script src="../Scripts/ValidateMessage_ZW.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            $("#form1").validate();
        });
    
    </script>
    <style type="text/css">
        .style1
        {
            height: 20px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <table class="maintable">
      <tr>
       <td colspan="2" class="titlebar"><span>客户文档信息编辑/下载</span></td>
      </tr>
       <tr>
           <td class="style1">主题</td><td class="style1"><asp:TextBox ID="txtsubJect" runat="server" CssClass="required"></asp:TextBox></td>
       </tr>
       <tr>
           <td class="style1">文件名</td><td class="style1">
           <asp:Label ID="lbName" runat="server" Text=""></asp:Label>
           </td>
       </tr>
       <tr>
           <td class="style1">文件扩展名</td><td class="style1">
           <asp:Label ID="lbExtendName" runat="server" Text=""></asp:Label>
           </td>
       </tr>
       <tr>
           <td class="style1">文件大小</td><td class="style1">
           <asp:Label ID="lbSize" runat="server" Text=""></asp:Label>
           </td>
       </tr>
       <tr>
           <td class="style1">上传用户</td><td class="style1">

            <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><input type="button" value="选择客户" style=" width:100px;" onclick="showDialog()" />
           </td>
       </tr>
      <tr>
            <td>
                文档等级</td>
          <td>
              <asp:DropDownList ID="ddlLevel" runat="server">
                  <asp:ListItem Selected="True">一般文件</asp:ListItem>
                  <asp:ListItem>重要文件</asp:ListItem>
                  <asp:ListItem>非常重要文件</asp:ListItem>
                  <asp:ListItem>特别重要</asp:ListItem>
              </asp:DropDownList>
          </td>
      </tr>
        <tr>
            <td>
                文档选择</td>
          <td>
              <asp:FileUpload ID="FileUpload1" runat="server" />
              <asp:LinkButton ID="lbtndown" runat="server">下载此文档</asp:LinkButton>
          </td>
      </tr>
          <tr>
            <td>
              所属客户
          </td>
          <td >
              <asp:TextBox ID="txtCustomerID" runat="server"></asp:TextBox><input type="button" value="选择客户" style=" width:100px;" onclick="showCustomerDialog()" />
          </td> 
      </tr>
          <tr>
            <td>
                说明</td>
          <td >
              <asp:TextBox ID="txtRemark" TextMode="MultiLine" Rows="5" runat="server" 
                  Width="380px"></asp:TextBox>
          </td> 
      </tr>
          <tr>
            <td>
                是否删除</td>
          <td >
              <asp:CheckBox ID="cbDelete" runat="server" />
          </td> 
      </tr>
         <tr>
             <td colspan="2" class="bottomtd">
             
                 <asp:HiddenField ID="hf_CustomerDocumentID" runat="server" />
             
                 <asp:Button ID="btnSubmit" runat="server" Text="文档编辑保存" 
                     onclick="btnSubmit_Click" />
                                  
                 <asp:Button ID="btnReturn" runat="server" Text="返回列表" onclick="btnReturn_Click" 
                     />
             
               
             </td>
         </tr>

     </table>
        <br />
    </div>
    </form>
</body>
</html>

文件下载的流程:

技术分享

技术分享

 

     /// <summary>
      /// 通过id获取视图对象
      /// </summary>
      /// <param name="id"></param>
      /// <returns></returns>
      public DocumentInfoView getDocumentViewByID(string id)
      {
         SqlDataReader reader= SqlComm.GetDataReaderByCondition("View_DoucmentInfo", "*", " DocumentID=" + id);
         DocumentInfoView documentview = null;     
         while (reader.Read())
         {          
             documentview = new DocumentInfoView() {
             UserID = int.Parse(reader["UserID"].ToString()),
             CustomerID = int.Parse(reader["CustomerID"].ToString()),
             CustomerName = reader["CustomerName"].ToString(),
             DocumentID =int.Parse(reader["DocumentID"].ToString()),
             DocumentLevel = reader["DocumentLevel"].ToString(),
             DocumentSize=Convert.ToInt64(reader["DocumentSize"].ToString()),
              ExetendName=reader["ExetendName"].ToString(),
             Name = reader["Name"].ToString(),
             Remark = reader["Remark"].ToString(),
             Subject = reader["Subject"].ToString(),
             Type = reader["Type"].ToString(),
             UploadTime=Convert.ToDateTime(reader["UploadTime"].ToString()),
             Content=null,
             DeleteState =Convert.ToBoolean(reader["DeleteState"].ToString()),
             CustomerDocumentID=int.Parse( reader["CustomerDocumentID"].ToString())
             };
         }
         reader.Close();
         return documentview;
      }

 下载和修改的后台代码:

 public partial class DocumentEditAndDown : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["Userid"] = "29";
            if (Request.QueryString["ID"] == null)
            {
                Response.Redirect("DocumentListShow.aspx");
            }
            if (!IsPostBack)
            {
                Pageinfoband();
            }
        }
    
        private void Pageinfoband()
        {
            if (Request.QueryString["ID"] != null)
            {
                string id = Request.QueryString["ID"].ToString();
                BioCrmCorrelationDocumentBLL dbll = new BioCrmCorrelationDocumentBLL();
                DocumentInfoView dv = new DocumentInfoView();
                dv=dbll.getDocumentViewByID(id);
                this.txtsubJect.Text = dv.Subject;
                this.txtRemark.Text = dv.Remark;
                this.txtCustomerID.Text = dv.CustomerID.ToString();
                this.ddlLevel.SelectedItem.Text = dv.DocumentLevel;
                this.cbDelete.Checked = dv.DeleteState;

                this.lbExtendName.Text = dv.ExetendName;
                this.lbName.Text = dv.Name;
           
                this.lbSize.Text = dv.DocumentSize.ToString();
                this.txtUserName.Text = dv.UserID.ToString();
                this.hf_CustomerDocumentID.Value = dv.CustomerDocumentID.ToString();

            }
        }
        
        /// <summary>
        /// 保存编辑内容
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            BioCrmCorrelationDocument document = new BioCrmCorrelationDocument();
            document.DocumentID =int.Parse( Request.QueryString["ID"].ToString());
            document.Subject = this.txtsubJect.Text;
            document.Name =DateTime.Now.ToString("yyyyMMdd hhmmss")+ this.FileUpload1.FileName;
            document.UserID =int.Parse(Session["Userid"].ToString());
            document.Remark = this.txtRemark.Text;
            document.DocumentLevel = this.ddlLevel.SelectedValue;
            document.Content = this.FileUpload1.FileBytes;
            document.DocumentSize=this.FileUpload1.FileContent.Length;
            document.Type=this.FileUpload1.PostedFile.ContentType;
            document.UploadTime = DateTime.Now;
            document.ExetendName=System.IO.Path.GetExtension(this.FileUpload1.FileName);
            //物理文件上传
            string filepath = Server.MapPath(@"\Files\CRMFiles\");
            if (Comm.FileExists(filepath + this.lbName.Text))
            {
                Comm.FileDelete(filepath + this.lbName.Text);
            }

            Comm.FileUpLoad(this.FileUpload1, filepath, document.Name);
            
            BioCrmCorrelationDocumentBLL documentbll = new BioCrmCorrelationDocumentBLL();
            //文档信息添加 包括文件上传(转换为二进制数组后上传)
            int count= documentbll.BioCrmCorrelationDocumentUpdate(document);
            //文档信息添加成功
            if (count != 0)
            {
                BioCrmCustomerDocument customerdocument = new BioCrmCustomerDocument();
                customerdocument.CustomerDocumentID = int.Parse(this.hf_CustomerDocumentID.Value);
                customerdocument.CustomerID = int.Parse(this.txtCustomerID.Text);
                customerdocument.DeleteState =cbDelete.Checked;
                customerdocument.DocumentID = document.DocumentID;
                BioCrmCustomerDocumentBLL customerdocumentbll = new BioCrmCustomerDocumentBLL();
                   int count1= customerdocumentbll.BioCrmCustomerDocumentUpdate(customerdocument);
                   if (count1 == 0)
                   {
                       SqlComm.DeleteTableByCondition("BioCrmCorrelationDocument", "where DocumentID=" + document.DocumentID);
                   }
                   else
                   {
                       Response.Redirect("DocumentListShow.aspx");
                   }
            }
            
           

        }

        protected void btnReturn_Click(object sender, EventArgs e)
        {
            Server.Transfer("DocumentListShow.aspx");
        }
       
    }
}

 

ERP联系记录管理(十七)

标签:ie8   adsi   lcx   hack   联系人   waf   hdu   cte   create   

原文地址:http://www.cnblogs.com/sunliyuan/p/6012169.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!