ERP渠道活动管理(二十六)

设计意义:

渠道活动的方式方法多种多样。不过,大至可分为销售型促销与市场型促销(一般来说,销售型促销以完成销售额为唯一目的,以奖励返点为唯一手段,以增大经销商库存为最终结果,短期行为明显。而市场型促销以完成销售额为最终目的—不是唯一目的,以市场的管理工作、市场基础投入、培训导购、终端建设、卖场活性化、现场促销、市场研究等为手段,以市场的良性建康发展为结果。

需求:

1.基本信息:
         活动名称,所属渠道,活动时间,活动地点,活动负责人,活动描述,状态。
2.相关业务:
        活动信息记录,活动信息查询,活动信息修改(改变状态)。

存储过程的封装:

CREATE PROCEDURE BioErpCrmChannelActivity_ADD
@ActiveName nvarchar(100),
@ChannelID int,
@ActivityTime datetime,
@ActivityAddress nvarchar(100),
@Principal nvarchar(10),
@ActivityDesc nvarchar(4000)
 AS 
	INSERT INTO [BioErpCrmChannelActivity](
	[ActiveName],[ChannelID],[ActivityTime],[ActivityAddress],[Principal],[ActivityDesc]
	)VALUES(
	@ActiveName,@ChannelID,@ActivityTime,@ActivityAddress,@Principal,@ActivityDesc
	)
CREATE PROCEDURE BioErpCrmChannelActivity_Update
@ActivityID int,
@ActiveName nvarchar(100),
@ChannelID int,
@ActivityTime datetime,
@ActivityAddress nvarchar(100),
@Principal nvarchar(10),
@ActivityDesc nvarchar(4000),
@DeleteState bit
 AS 
	UPDATE [BioErpCrmChannelActivity] SET 
	[ActiveName] = @ActiveName,[ChannelID] = @ChannelID,[ActivityTime] = @ActivityTime,[ActivityAddress] = @ActivityAddress,[Principal] = @Principal,[ActivityDesc] = @ActivityDesc,[DeleteState] = @DeleteState
	WHERE ActivityID=@ActivityID 

创建活动编号返回活动的视图:

CREATE VIEW dbo.View_CRMChannelActivity
AS
SELECT     dbo.BioErpCrmManageChannel.ChannelName, dbo.BioErpCrmChannelActivity.*
FROM         dbo.BioErpCrmChannelActivity INNER JOIN
                      dbo.BioErpCrmManageChannel ON dbo.BioErpCrmChannelActivity.ChannelID = dbo.BioErpCrmManageChannel.ChannelID

BLL层:

       /// <summary>
       /// 添加一条活动信息
       /// </summary>
       /// <param name="active"></param>
       /// <returns></returns>
       public int ChannelActiveAdd(BioErpCrmChannelActivity active)
       {

           SqlParameter[] pars = new SqlParameter[]{
            new SqlParameter("@ChannelID",active.ChannelID),
            new SqlParameter("@ActiveName",active.ActiveName),
            new SqlParameter("@ActivityTime",active.ActivityTime),
            new SqlParameter("@ActivityAddress",active.ActivityAddress),
            new SqlParameter("@Principal",active.Principal),
            new SqlParameter("@ActivityDesc",active.ActivityDesc),
           };

           return DAL.DataBaseHelper.ExcuteSqlReturnInt("BioErpCrmChannelActivity_ADD",CommandType.StoredProcedure,pars);

       }

     
       /// <summary>
       /// 修改一条活动信息
       /// </summary>
       /// <param name="active"></param>
       /// <returns></returns>
       public int ChannelActiveUpdate(BioErpCrmChannelActivity active)
       {

           SqlParameter[] pars = new SqlParameter[]{
            new SqlParameter("@ActivityID",active.ActivityID),
            new SqlParameter("@ChannelID",active.ChannelID),
            new SqlParameter("@ActiveName",active.ActiveName),
            new SqlParameter("@ActivityTime",active.ActivityTime),
            new SqlParameter("@ActivityAddress",active.ActivityAddress),
            new SqlParameter("@Principal",active.Principal),
            new SqlParameter("@ActivityDesc",active.ActivityDesc),
           };

           return DAL.DataBaseHelper.ExcuteSqlReturnInt("BioErpCrmChannelActivity_Update", CommandType.StoredProcedure, pars);

       }
     

       /// <summary>
       /// 根据活动编号返回活动的视图对象
       /// </summary>
       /// <param name="id">id</param>
       /// <returns>ViewCRMChannelActivity</returns>
       public ViewCRMChannelActivity getViewActiveityByActivityID(string id)
       {
        SqlDataReader reader= SqlComm.GetDataReaderByCondition("View_CRMChannelActivity", "*", " id=" + id);
        ViewCRMChannelActivity active = null;
        while (reader.Read())
        {
            active = new ViewCRMChannelActivity()
            {
                ActiveName = reader["ActiveName"].ToString(),
                ActivityAddress = reader["ActivityAddress"].ToString(),
                ActivityDesc = reader["ActivityDesc"].ToString(),
                ActivityID =int.Parse( reader["ActivityID"].ToString()),
                ActivityTime = Convert.ToDateTime(reader["ActivityTime"].ToString()),
                ChannelID = int.Parse(reader["ChannelID"].ToString()),
                ChannelName = reader["ChannelName"].ToString(),
                DeleteState =Convert.ToBoolean( reader["DeleteState"].ToString()),
                Principal = reader["Principal"].ToString()
            };
        }
        reader.Close();
        return active;      
       }

 添加的前端:

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

<!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/ChannelChoose.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/jquery.metadata.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="txtName" runat="server" CssClass="required"></asp:TextBox></td>
       </tr>

        <tr>
            <td>
                所属渠道
          </td>
          <td >
              <asp:TextBox ID="txtSuperChannelID"  CssClass="{required:true,number:true, min:1}" runat="server"></asp:TextBox><input type="button" value="选择" style=" width:100px;" onclick="showChannel()" />
          </td> 
      </tr>
      <tr>
            <td>
                活动负责人</td>
          <td>
              <asp:TextBox ID="txtPrincipal" runat="server" CssClass="required"></asp:TextBox>
          </td>
      </tr>
        <tr>
            <td>活动时间</td>
          <td>
               <asp:TextBox ID="txtTime" runat="server" CssClass="required"></asp:TextBox>
          </td>
      </tr>
                <tr>
            <td>活动地点</td>
          <td>
               <asp:TextBox ID="txtAddress" runat="server" CssClass="required"></asp:TextBox>
          </td>
      </tr>
          <tr>
            <td>
                活动描述</td>
          <td >
              <asp:TextBox ID="txtActivityDesc" 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="返回列表" UseSubmitBehavior="false" onclick="btnReturn_Click" 
                     />
             </td>
         </tr>

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

添加的后端代码:

 protected void btnSubmit_Click(object sender, EventArgs e)
        {

            BioErpCrmChannelActivity activity = new BioErpCrmChannelActivity()
            {
                ActiveName = this.txtName.Text,
                Principal = this.txtPrincipal.Text,
                ActivityAddress = this.txtAddress.Text,
                ActivityTime = Convert.ToDateTime(this.txtTime.Text.ToString()),
                ActivityDesc = this.txtActivityDesc.Text.Trim(),
                ChannelID = int.Parse(this.txtSuperChannelID.Text.Trim())
            };
            ChannelActiveBLL activebll = new ChannelActiveBLL();
            if (activebll.ChannelActiveAdd(activity) != 0)
            {
                Server.Transfer("ChannelAcitiveListShow.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('活动记录提交失败')", true);
            }
        }

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

 前端查询和显示的代码:

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

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

<%@ Register src="../../UserControl/CRMChannelMenuBar.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" />
    <link href="../../Scripts/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
    <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 type="text/javascript">
        $().ready(function () {
            $("#txtDate").datepicker({dateFormat:'yy-mm-dd'});
        });
    </script>
</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" Width="80px" runat="server"></asp:TextBox>
                 </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label2" runat="server" Text="渠道名:"></asp:Label>
                      <asp:TextBox ID="txtCName" Width="80px" runat="server"></asp:TextBox>
              </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label3" runat="server" Text="活动时间:"></asp:Label>
                     <asp:TextBox ID="txtDate" Width="80px" runat="server"></asp:TextBox>
                      
                 </td>
                      <td class="tdsearch">
                     <asp:Label ID="Label8" runat="server" Text="活动状态:"></asp:Label>
                          <asp:DropDownList ID="ddlSate" runat="server">
                            <asp:ListItem  Text="未完成" Value="0"></asp:ListItem>
                          <asp:ListItem  Text="已完成" Value="1"></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="ActivityID">
                         <Columns>
                             <asp:TemplateField HeaderText="活动名称" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label4" runat="server" Text='<%# Eval("ActiveName") %>'></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("ChannelName") %>'></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="负责人">
                                 <ItemTemplate>
                                     <asp:Label ID="lbpri" runat="server" Text='<%# Eval("Principal") %>'></asp:Label>
                                 </ItemTemplate>                                 
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="活动地点" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label7" runat="server" Text='<%# Eval("ActivityAddress") %>'></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='<%# Convert.ToDateTime( Eval("ActivityTime")).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="Label10" runat="server" Text='<%# Eval("ActivityDesc").ToString().Length>10 ?Eval("ActivityDesc").ToString().Substring(0,10)+"…":Eval("ActivityDesc").ToString()  %>'></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:HyperLinkField DataNavigateUrlFields="ActivityID" DataNavigateUrlFormatString="ChannelAcitiveDetial.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>

 查询的代码:

 /// <summary>
        /// 查询所有联系人信息
        /// </summary>
        private void getallPageList()
        {
            string id = Session["Userid"].ToString();
            //condition += " and UserID=" + id;
            //if (UserLogin.user.RoleId == 6) //市场部经理
            //{
            //    condition  += " or UserID !=" + id;
            //}
            this.AspNetPager1.RecordCount = SqlComm.getDataCountByCondition("dbo.View_CRMChannelActivity", condition);
            this.AspNetPager1.PageSize = pagesize;
            this.GridView1.DataSource = SqlComm.getDataByPageIndex("dbo.View_CRMChannelActivity", "*", "ActivityID", 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 ActiveName like '" + txtName.Text + "%'";
            }

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

            if (this.txtDate.Text.Trim() != null && this.txtDate.Text.Trim().Length!=0)
            {
                condition = condition + " and (ActivityTime >= '" + this.txtDate.Text + "' AND ActivityTime< '" + Convert.ToDateTime(this.txtDate.Text).AddDays(1) + "')";
            }

           
            condition = condition + " and DeleteState=" + this.ddlSate.SelectedValue.ToString();
                 

            getallPageList();

        }

 活动记录显示:

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

<!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/ChannelChoose.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/jquery.metadata.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:Label ID="txtName" runat="server"></asp:Label></td>
       </tr>

        <tr>
            <td>
                所属渠道
          </td>
          <td >
              <asp:Label ID="txtSuperChannelID"  runat="server"></asp:Label> </td> 
      </tr>
      <tr>
            <td>
                活动负责人</td>
          <td>
              <asp:Label ID="txtPrincipal" runat="server" ></asp:Label>
          </td>
      </tr>
        <tr>
            <td>活动时间</td>
          <td>
               <asp:Label ID="txtTime" runat="server"></asp:Label>
          </td>
      </tr>
                <tr>
            <td>活动地点</td>
          <td>
               <asp:Label ID="txtAddress" runat="server" ></asp:Label>
          </td>
      </tr>
          <tr>
            <td>
                活动描述</td>
          <td >
              <asp:Label ID="txtActivityDesc"  runat="server" ></asp:Label>
          </td> 
      </tr>
          <tr>
            <td>
                活动状态</td>
          <td >
              <asp:Label ID="ddlSate" runat="server" Text="Label"></asp:Label>
          </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="返回" UseSubmitBehavior="false" onclick="btnReturn_Click" 
                     />
             </td>
         </tr>

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

 活动记录后台:

    public void pageinfo()
        {
            if (Request.QueryString["ID"] == null)
            {
                Response.Redirect("ChannelAcitiveListShow.aspx");
                return;
            }

           string id= Request.QueryString["ID"].ToString();
           ViewCRMChannelActivity active = new ViewCRMChannelActivity();
           ChannelActiveBLL activebll = new ChannelActiveBLL();
           active=  activebll.getViewActiveityByActivityID(id);
           this.txtTime.Text = active.ActivityTime.ToString();
           this.txtSuperChannelID.Text = active.ChannelName + "(编号:" + active.ChannelID + ")";
           this.txtPrincipal.Text = active.Principal;
           this.txtName.Text = active.ActiveName;
           this.txtAddress.Text = active.ActivityAddress;
           this.txtActivityDesc.Text = active.ActivityDesc;
           this.ddlSate.Text =Convert.ToBoolean(active.DeleteState) ? "已完成" : "未完成";
                

        }
        
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            Server.Transfer("ChannelAcitiveEidt.aspx?ID="+Request.QueryString["ID"]);
        }

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

 编辑的前端:

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

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

<%@ Register src="../../UserControl/CRMChannelMenuBar.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" />
    <link href="../../Scripts/jquery-ui-1.7.custom.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.7.custom.min.js" type="text/javascript"></script>
    <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 type="text/javascript">
        $().ready(function () {
            $("#txtDate").datepicker({dateFormat:'yy-mm-dd'});
        });
    </script>
</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" Width="80px" runat="server"></asp:TextBox>
                 </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label2" runat="server" Text="渠道名:"></asp:Label>
                      <asp:TextBox ID="txtCName" Width="80px" runat="server"></asp:TextBox>
              </td>
                 <td class="tdsearch">
                     <asp:Label ID="Label3" runat="server" Text="活动时间:"></asp:Label>
                     <asp:TextBox ID="txtDate" Width="80px" runat="server"></asp:TextBox>
                      
                 </td>
                      <td class="tdsearch">
                     <asp:Label ID="Label8" runat="server" Text="活动状态:"></asp:Label>
                          <asp:DropDownList ID="ddlSate" runat="server">
                            <asp:ListItem  Text="未完成" Value="0"></asp:ListItem>
                          <asp:ListItem  Text="已完成" Value="1"></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="ActivityID">
                         <Columns>
                             <asp:TemplateField HeaderText="活动名称" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label4" runat="server" Text='<%# Eval("ActiveName") %>'></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("ChannelName") %>'></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="负责人">
                                 <ItemTemplate>
                                     <asp:Label ID="lbpri" runat="server" Text='<%# Eval("Principal") %>'></asp:Label>
                                 </ItemTemplate>                                 
                             </asp:TemplateField>
                             <asp:TemplateField HeaderText="活动地点" HeaderStyle-HorizontalAlign="Center">
                                 <ItemTemplate>
                                     <asp:Label ID="Label7" runat="server" Text='<%# Eval("ActivityAddress") %>'></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='<%# Convert.ToDateTime( Eval("ActivityTime")).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="Label10" runat="server" Text='<%# Eval("ActivityDesc").ToString().Length>10 ?Eval("ActivityDesc").ToString().Substring(0,10)+"…":Eval("ActivityDesc").ToString()  %>'></asp:Label>
                                 </ItemTemplate>
                                 <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                 <ItemStyle HorizontalAlign="Center" />
                             </asp:TemplateField>
                             <asp:HyperLinkField DataNavigateUrlFields="ActivityID" DataNavigateUrlFormatString="ChannelAcitiveDetial.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>

 后台代码:

    protected void Page_Load(object sender, EventArgs e)
        {
            Session["Userid"] = "29";

            if (Request.QueryString["ID"] == null)
            {
                Response.Redirect("ChannelAcitiveListShow.aspx");
                return;
            }

            if (!IsPostBack)
            {
                pageinfo();
            }
        }
        public void pageinfo()
        {
            if (Request.QueryString["ID"] == null)
            {
                Response.Redirect("ChannelAcitiveListShow.aspx");
                return;
            }

            string id = Request.QueryString["ID"].ToString();
            ViewCRMChannelActivity active = new ViewCRMChannelActivity();
            ChannelActiveBLL activebll = new ChannelActiveBLL();
            active = activebll.getViewActiveityByActivityID(id);
            this.txtTime.Text = active.ActivityTime.ToString();
            this.txtSuperChannelID.Text =  active.ChannelID.ToString();
            this.txtPrincipal.Text = active.Principal;
            this.txtName.Text = active.ActiveName;
            this.txtAddress.Text = active.ActivityAddress;
            this.txtActivityDesc.Text = active.ActivityDesc;
            this.ddlSate.SelectedValue = Convert.ToBoolean(active.DeleteState) ? "1" : "0";
        }
       
        
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

           string ID=  Request.QueryString["ID"].ToString();
            BioErpCrmChannelActivity activity = new BioErpCrmChannelActivity()
            {
                ActivityID=int.Parse(ID),
                ActiveName = this.txtName.Text,
                Principal = this.txtPrincipal.Text,
                ActivityAddress = this.txtAddress.Text,
                ActivityTime = Convert.ToDateTime(this.txtTime.Text.ToString()),
                ActivityDesc = this.txtActivityDesc.Text.Trim(),
                ChannelID = int.Parse(this.txtSuperChannelID.Text.Trim()),
                DeleteState=ddlSate.SelectedValue.ToString()=="0"?false :true
                 

            };
            ChannelActiveBLL activebll = new ChannelActiveBLL();
            if (activebll.ChannelActiveUpdate(activity) != 0)
            {
                Server.Transfer("ChannelAcitiveListShow.aspx");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "test", "alert('活动记录编辑失败')", true);
            }
        }

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

 

posted @ 2017-07-17 21:45  石shi  阅读(425)  评论(0编辑  收藏  举报