コード例 #1
0
    /// <summary>
    /// 修改数据到数据库
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gvLeadSourceses_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        int leadSourceID = 0;

        if (gvLeadSourceses.DataKeys[e.RowIndex] != null)
        {
            leadSourceID = int.Parse(gvLeadSourceses.DataKeys[e.RowIndex].Values[0].ToString());
        }

        string leadSource    = ((TextBox)gvLeadSourceses.Rows[e.RowIndex].FindControl("txtLeadSource")).Text;
        int    defaultUserId = int.Parse(((DropDownList)gvLeadSourceses.Rows[e.RowIndex].FindControl("ddlDefaultUser")).SelectedValue);
        bool   isDefault     = ((CheckBox)gvLeadSourceses.Rows[e.RowIndex].FindControl("cbxDefaultStr")).Checked;

        bllLeadSource.UpdateDefault(isDefault);

        LPWeb.Model.Company_Lead_Sources leadSourceModel = new LPWeb.Model.Company_Lead_Sources();
        leadSourceModel.LeadSourceID  = leadSourceID;
        leadSourceModel.LeadSource    = leadSource;
        leadSourceModel.DefaultUserId = defaultUserId;
        leadSourceModel.Default       = isDefault;

        try
        {
            bllLeadSource.Update(leadSourceModel);
        }
        catch (Exception exception)
        {
            LPLog.LogMessage(exception.Message);
        }

        gvLeadSourceses.EditIndex = -1;
        FillDataGrid(string.Empty);
    }
コード例 #2
0
    /// <summary>
    /// 添加一条新的数据到数据库
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddSave_Click(object sender, EventArgs e)
    {
        var tbxLeadSource  = gvLeadSourceses.FooterRow.FindControl("tbxLeadSource") as TextBox;
        var ddlDefaultUser = gvLeadSourceses.FooterRow.FindControl("ddlUsers") as DropDownList;
        var cbxDefault     = gvLeadSourceses.FooterRow.FindControl("cbxDefaultStr") as CheckBox;

        var record = new LPWeb.Model.Company_Lead_Sources
        {
            LeadSource    = tbxLeadSource.Text.Trim(),
            Default       = cbxDefault.Checked,
            DefaultUserId = int.Parse(ddlDefaultUser.SelectedValue),
        };

        try
        {
            //更新Default
            bllLeadSource.UpdateDefault(cbxDefault.Checked);

            bllLeadSource.Add(record);
        }
        catch (Exception exception)
        {
            LPLog.LogMessage(exception.Message);
        }
        gvLeadSourceses.ShowFooter = false;
        lbtnAdd.Text = "Add";
        FillDataGrid(string.Empty);
    }
コード例 #3
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <LPWeb.Model.Company_Lead_Sources> DataTableToList(DataTable dt)
        {
            List <LPWeb.Model.Company_Lead_Sources> modelList = new List <LPWeb.Model.Company_Lead_Sources>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                LPWeb.Model.Company_Lead_Sources model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new LPWeb.Model.Company_Lead_Sources();
                    if (dt.Rows[n]["LeadSourceID"].ToString().Length > 0)
                    {
                        model.LeadSourceID = int.Parse(dt.Rows[n]["LeadSourceID"].ToString());
                    }
                    model.LeadSource = dt.Rows[n]["LeadSource"].ToString();

                    if (dt.Rows[n]["DefaultUser"] != DBNull.Value)
                    {
                        model.DefaultUser = dt.Rows[n]["DefaultUser"].ToString();
                    }
                    else
                    {
                        model.DefaultUser = "";
                    }

                    if (dt.Rows[n]["DefaultUserId"] != DBNull.Value || dt.Rows[n]["DefaultUserId"].ToString().Length > 0)
                    {
                        model.DefaultUserId = int.Parse(dt.Rows[n]["DefaultUserId"].ToString());
                    }
                    //else
                    //{
                    //    model.DefaultUserId = -1;
                    //}

                    model.DefaultString = dt.Rows[n]["DefaultString"].ToString();

                    if (dt.Rows[n]["Default"] != DBNull.Value && dt.Rows[n]["Default"].ToString().Length > 0)
                    {
                        model.Default = bool.Parse(dt.Rows[n]["Default"].ToString());
                    }
                    //else
                    //{
                    //    model.Default = false;
                    //}

                    modelList.Add(model);
                }
            }
            return(modelList);
        }
コード例 #4
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(LPWeb.Model.Company_Lead_Sources model)
 {
     dal.Update(model);
 }
コード例 #5
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(LPWeb.Model.Company_Lead_Sources model)
 {
     return(dal.Add(model));
 }