コード例 #1
0
    public bool Add(Ext.Net.Component wrapperComponent, string tableName, string[] parameters, string [] values)
    {
        try
        {
            string sql = "insert into " + tableName + "({0}) values({1})";

            for (int i = 0; i < parameters.Count(); i++)
            {
                if (!string.IsNullOrEmpty(parameters[i]))
                {
                    ColumnName  += "[" + parameters[i] + "],";
                    ValueList   += "N'" + values[i] + "',";
                    UpdateQuery += "[" + parameters[i] + "] = N'" + values[i] + "',";
                }
            }
            GetChildControl(wrapperComponent);
            //     sql = string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")));
            return(DataController.DataHandler.GetInstance().ExecuteNonQuery(string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")))) > 0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
コード例 #2
0
    /// <summary>
    /// Tiến hành insert một bản ghi vào CSDL
    /// </summary>
    /// <param name="wrapperComponent">container chứa các control</param>
    /// <param name="tableName">Tên bảng muốn insert</param>
    /// <returns></returns>
    ///

    public bool Add(Ext.Net.Component wrapperComponent, string tableName)
    {
        try
        {
            string sql = "insert into " + tableName + "({0}) values({1})";
            GetChildControl(wrapperComponent);
            //     sql = string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")));
            return(DataController.DataHandler.GetInstance().ExecuteNonQuery(string.Format(sql, ColumnName.Remove(ColumnName.LastIndexOf(",")), ValueList.Remove(ValueList.LastIndexOf(",")))) > 0);
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }