Example #1
0
    public int Add(BookPartEntity data)
    {
        string sql = this.AddSql(data);
        int    x   = this.dbHelper.whriteData(sql);

        return(x);
    }
Example #2
0
    //Add
    internal string AddSql(BookPartEntity data)
    {
        string colNames = "";
        string colValue = "";

        colNames += " Id ";
        colValue += " " + this.GetNewId() + " ";

        colNames += ",Name_Ar";
        colValue += ",'" + data.Name_Ar + "'";

        colNames += ",Name_En";
        colValue += ",'" + data.Name_En + "'";

        colNames += ",BookId";
        colValue += "," + data.BookData.Id + "";

        colNames += ",RowId";
        colValue += ",'" + data.RowId + "'";

        colNames += ",DateMade";
        colValue += ",'" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        colNames += ",MadeById";
        colValue += "," + data.MadeById + "";

        //-------------------------------
        string sql = " INSERT INTO BookParts ( " + colNames + " ) VALUES ( " + colValue + " ) ";

        return(sql);
    }
Example #3
0
    public int Update(int id, BookPartEntity data)
    {
        string sql = this.UpdateSql(id, data);

        int x = this.dbHelper.whriteData(sql);

        return(x);
    }
Example #4
0
    private void SetData(DataRow Row, BookPartEntity data)
    {
        data.Id          = Row["Id"].ToString().ToIntVal();
        data.Name_Ar     = Row["Name_Ar"].ToString();
        data.Name_En     = Row["Name_En"].ToString();
        data.BookData.Id = Row["BookId"].ToString().ToIntVal();
        data.RowId       = Row["RowId"].ToString();
        data.DateMade    = Row["DateMade"].ToString().ToDateVal();

        data.MadeById = Row["MadeById"].ToString().ToIntVal();
    }
Example #5
0
    //Update
    public string UpdateSql(int id, BookPartEntity data)
    {
        string sql = "UPDATE BookParts SET   ";

        sql += " Name_Ar = '" + data.Name_Ar + "' ";
        sql += ",Name_En = '" + data.Name_En + "' ";
        sql += ",BookId = " + data.BookData.Id + " ";
        //---------------
        sql += ",DateMade = '" + this.dbHelper.GetServerDate().ToDateVal().FormatDate("MM/dd/yyyy HH:mm") + "'";

        sql += ",MadeById = " + data.MadeById + "";

        sql += " WHERE Id = " + id + " ";

        return(sql);
    }
Example #6
0
    public bool GetData()
    {
        bool           x    = false;
        BookPartEntity data = delGetData(this.Id);

        if (!data.IsNull_Ex())
        {
            x             = true;
            this.Id       = data.Id;
            this.DateMade = data.DateMade;

            this.MadeById    = data.MadeById;
            this.Name_Ar     = data.Name_Ar;
            this.Name_En     = data.Name_En;
            this.BookData.Id = data.BookData.Id;
            this.RowId       = data.RowId;
        }
        return(x);
    }
Example #7
0
    public BookPartEntity GetData(string rowId)
    {
        BookPartEntity data = null;

        DataTable table;
        string    sql = this.GetSql();

        sql += " WHERE RowId = '" + rowId + "' ";

        table = this.dbHelper.retriveData(sql);


        if (table != null && table.Rows.Count > 0)
        {
            DataRow row = table.Rows[0];

            data = new BookPartEntity();
            this.SetData(row, data);
        }

        return(data);
    }
Example #8
0
    public List <BookPartEntity> GetList()
    {
        List <BookPartEntity> lst = null;

        DataTable table;
        string    sql = this.GetSql();

        table = this.dbHelper.retriveData(sql);

        if (table != null && table.Rows.Count > 0)
        {
            lst = new List <BookPartEntity>();

            foreach (DataRow row in table.Rows)
            {
                BookPartEntity data = new BookPartEntity();
                this.SetData(row, data);

                lst.Add(data);
            }
        }
        return(lst);
    }