Exemplo n.º 1
0
 /*
  * ردیف اضافه می کنیم
  *
  */
 protected void fillRadif(AbstractCommonData entity)
 {
     for (int i = 0; i < entity.Tables[entity.FilledTableName].Rows.Count; i++)
     {
         entity.Tables[entity.FilledTableName].Rows[i][AbstractCommonData.FIELD_RADIF] = i + 1;
     }
 }
Exemplo n.º 2
0
        public static string getData(AbstractCommonData dataSet, ArrayList selectedFields, ArrayList selectedFieldsTitle)
        {
            if (selectedFieldsTitle.Count < 2)
            {
                return("");
            }
            string data = "";
            string flds = "";
            string t;

            for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
            {
                t = generalizeData(selectedFields[0].ToString(), dataSet.Tables[0].Rows[i][selectedFields[0].ToString()].ToString().Trim());

                flds = "<Row>\n\t<Cell ss:Index=\"1\"><Data ss:Type=\"String\">" + t + "</Data></Cell>\n";
                for (int j = 1; j < selectedFields.Count; j++)
                {
                    if (selectedFields[j] == null || selectedFields[j].ToString().Length == 0)
                    {
                        t = "";
                    }
                    else
                    {
                        t = generalizeData(selectedFields[j].ToString(), dataSet.Tables[0].Rows[i][selectedFields[j].ToString()].ToString().Trim());
                    }
                    flds += "\t<Cell><Data ss:Type=\"String\">" + t + "</Data></Cell>\n";
                }
                data += flds + "</Row>\n";
            }
            return(data);
        }
Exemplo n.º 3
0
        public override void select(string query, AbstractCommonData dataSet, string tableName)
        {
            SqlCommand cmd = new SqlCommand(query, dbCon);

            sqlda.SelectCommand = cmd;
            sqlda.Fill(dataSet, tableName);
        }
Exemplo n.º 4
0
        public override void loadToDataSet(AbstractCommonData entity, string condition, string orderby, string filledTableName)
        {
            string query = "";

            if (filledTableName != null && filledTableName.Length > 0)
            {
                entity.FilledTableName = filledTableName;
            }
            else
            {
                entity.FilledTableName = entity.VIEW_QUALIFIRE + entity.TableName;
            }

            if (condition != null && condition.Length > 0)
            {
                query = "SELECT * FROM " + entity.FilledTableName + " WHERE " + condition;
            }
            else
            {
                query = "SELECT * FROM " + entity.FilledTableName;
            }
            if (orderby != null && orderby.Length > 0)
            {
                query += " ORDER BY " + orderby;
            }
            SqlCommand cmd = new SqlCommand(query, dbCon);

            if (sqlda != null)
            {
                sqlda.SelectCommand = cmd;
                sqlda.SelectCommand.CommandTimeout = 20 * 60;
                sqlda.Fill(entity, entity.FilledTableName);
                fillRadif(entity);
            }
        }
Exemplo n.º 5
0
        public override int update(AbstractCommonData entity)
        {
            SqlCommand cmd = new SqlCommand(entity.updatecmdWithIndexedWhereCluse, dbCon);

            sqlda.InsertCommand = cmd;
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            try
            {
                entity.Tables[entity.FilledTableName].Columns.Remove("RADIF");
            }
            catch (Exception ex) { }

            SqlParameterCollection sqlParams = cmd.Parameters;

            if (entity.FilledTableName == "")
            {
                entity.FilledTableName = entity.TableName;
            }
            for (int i = 0; i < entity.Tables[entity.FilledTableName].Columns.Count; i++)
            {
                string      p     = entity.Tables[entity.FilledTableName].Columns[i].Caption;
                System.Type type  = entity.Tables[entity.FilledTableName].Columns[i].GetType();
                object      value = entity.Tables[entity.FilledTableName].Rows[0][p];
                if (value != null)
                {
                    sqlParams.Add(new SqlParameter("@" + p, type));
                    sqlParams["@" + p].Value = value;
                }
            }

            return(cmd.ExecuteNonQuery());
            //cmd.Parameters.Add(
            //return sqlda.Update(dataSet);
        }
Exemplo n.º 6
0
        public int deleteWithIndexField(AbstractCommonData entity)
        {
            string sql = "delete from " + entity.TableName + " where " + entity.IndexFieldName + "=" +
                         provider.getSQLString(entity.Tables[entity.FilledTableName].Rows[0][entity.IndexFieldName].ToString());

            return(provider.executeNonQuery(sql));
        }
Exemplo n.º 7
0
        public override int update(AbstractCommonData dataSet, string tableName)
        {
            SqlCommand cmd = new SqlCommand(dataSet.updatecmdWithIndexedWhereCluse, dbCon);

            sqlda.InsertCommand = cmd;

            dataSet.Tables[0].Columns.Remove("RADIF");
            SqlParameterCollection sqlParams = cmd.Parameters;

            for (int i = 0; i < dataSet.Tables[tableName].Columns.Count; i++)
            {
                string      p     = dataSet.Tables[tableName].Columns[i].Caption;
                System.Type type  = dataSet.Tables[tableName].Columns[i].GetType();
                object      value = dataSet.Tables[tableName].Rows[0][p];
                if (value != null)
                {
                    sqlParams.Add(new SqlParameter("@" + p, type));
                    sqlParams["@" + p].Value = value;
                }
            }

            return(cmd.ExecuteNonQuery());
            //cmd.Parameters.Add(
            //return sqlda.Update(dataSet);
        }
Exemplo n.º 8
0
 /*
  * ردیف اضافه می کنیم
  *
  */
 protected void fillRadif(AbstractCommonData ds)
 {
     for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
     {
         ds.Tables[0].Rows[i][AbstractCommonData.RADIF_FIELD] = i + 1;
     }
 }
Exemplo n.º 9
0
        public void bindDataToGrid(DataGridView grid, AbstractCommonData entity, changingRow chageRow, Hashtable hash)
        {
            grid.Rows.Clear();

            int       columns = grid.ColumnCount;
            DataTable table   = entity.Tables[entity.FilledTableName];

            if (table == null)
            {
                throw new Exception("نا م جدول در دیتا ست یافت نشد");
            }

            string field;
            string colName = "";
            object value   = "";

            int currentRowIndex;

            for (int tableIndex = 0; tableIndex < table.Rows.Count; tableIndex++)
            {
                currentRowIndex = grid.Rows.Add();
                for (int gridIndex = 0; gridIndex < grid.Columns.Count; gridIndex++)
                {
                    field = grid.Columns[gridIndex].DataPropertyName;
                    if (field != null && field.Length > 0)
                    {
                        colName = grid.Columns[gridIndex].Name;
                        try
                        {
                            value = getAsString(table.Rows[tableIndex][field]);
                        }
                        catch (Exception ex)
                        {
                            value = "";
                        }
                        //cell = new DataGridViewCell();
                        //cell.Value = value;
                        if (colName.Equals("USERTYPE"))
                        {
                            if (grid.Rows[currentRowIndex].Cells[colName] is DataGridViewComboBoxCell)
                            {
                                ((DataGridViewComboBoxCell)grid.Rows[currentRowIndex].Cells[colName]).Value = value;
                            }
                        }
                        else
                        {
                            grid.Rows[currentRowIndex].Cells[colName].Value = value;
                        }
                    }
                }
                if (chageRow != null)
                {
                    chageRow(grid, currentRowIndex, hash);
                }
            }
        }
Exemplo n.º 10
0
        public override void executeSelect(string query, AbstractCommonData entity, string filledTableName)
        {
            SqlCommand cmd = new SqlCommand(query, dbCon);

            sqlda.SelectCommand = cmd;
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            sqlda.Fill(entity, filledTableName);
            entity.FilledTableName = filledTableName;
            fillRadif(entity);
        }
Exemplo n.º 11
0
        private int getNewId()
        {
            AbstractCommonData entity = new AbstractCommonData();
            string             sql    = "SELECT NEWID = @@IDENTITY";

            sqlda.SelectCommand = new SqlCommand(sql, dbCon);
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            sqlda.Fill(entity);
            int id = int.Parse(entity.Tables[0].Rows[0][0].ToString());

            return(id);
        }
Exemplo n.º 12
0
        private void fillGrid(string condition)
        {
            int id = int.Parse(UsersBS.loginedUser.Tables[UsersData.users_TABLE].Rows[0][UsersData.id_FIELD].ToString());

            System.Collections.Hashtable hash = new System.Collections.Hashtable();
            hash.Add("colorField", InsuranceTypeData.INSURANCETYPECOLOR_FIELD);
            _dataSource = new ViewInsuranceInfoBS().loadUserLimitedList(id, condition);
            _gridTools.bindDataToGrid(dataGridView1,
                                      _dataSource, ViewInsuranceInfoData.VIEW_INSURANCEINFO_TABLE
                                      , new GridTools.changingRow(_gridTools.changeColor), hash);

            selectCurrentRow();
        }
Exemplo n.º 13
0
        public override void select(AbstractCommonData entity, string cond)
        {
            entity.FilledTableName = entity.VIEW_QUALIFIRE + entity.TableName;
            string query = "SELECT * FROM " + entity.FilledTableName;

            if (cond != null && cond.Trim().Length > 0)
            {
                query += " WHERE " + cond;
            }

            SqlCommand cmd = new SqlCommand(query, dbCon);

            sqlda.SelectCommand = cmd;
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            sqlda.Fill(entity, entity.FilledTableName);
        }
Exemplo n.º 14
0
        public override void loadToDataSet(string tableName, AbstractCommonData dataSet, string condition)
        {
            string query = "";

            if (condition != null && condition.Length > 0)
            {
                query = "SELECT * FROM " + tableName + " WHERE " + condition;
            }
            else
            {
                query = "SELECT * FROM " + tableName;
            }
            SqlCommand cmd = new SqlCommand(query, dbCon);

            sqlda.SelectCommand = cmd;
            sqlda.Fill(dataSet, tableName);
        }
Exemplo n.º 15
0
        public override int delete(AbstractCommonData entity)
        {
            SqlCommand cmd = new SqlCommand(entity.deleteCmdWithIndexedWhereCluse, dbCon);

            sqlda.DeleteCommand = cmd;
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            SqlParameterCollection sqlParams = cmd.Parameters;

            for (int i = 0; i < entity.Tables[entity.FilledTableName].Columns.Count; i++)
            {
                string      p     = entity.Tables[entity.FilledTableName].Columns[i].Caption;
                System.Type type  = entity.Tables[entity.FilledTableName].Columns[i].GetType();
                object      value = entity.Tables[entity.FilledTableName].Rows[0][p];
                if (value != null)
                {
                    sqlParams.Add(new SqlParameter("@" + p, type));
                    sqlParams["@" + p].Value = value;
                }
            }
            cmd.ExecuteNonQuery();
            sqlda.Update(entity);
            return(0);
        }
Exemplo n.º 16
0
        public override int add(AbstractCommonData entity)
        {
            // sqlda.
            SqlCommand cmd = new SqlCommand(entity.insertCommand, dbCon);

            sqlda.InsertCommand = cmd;
            sqlda.SelectCommand.CommandTimeout = 20 * 60;
            SqlParameterCollection sqlParams = cmd.Parameters;

            for (int i = 0; i < entity.Tables[entity.TableName].Columns.Count; i++)
            {
                string      p     = entity.Tables[entity.TableName].Columns[i].Caption;
                System.Type type  = entity.Tables[entity.TableName].Columns[i].GetType();
                object      value = entity.Tables[entity.TableName].Rows[0][p];
                if (value != null)
                {
                    sqlParams.Add(new SqlParameter("@" + p, type));
                    sqlParams["@" + p].Value = value;
                }
            }
            cmd.ExecuteScalar();

            return(getNewId());
        }
Exemplo n.º 17
0
 /// <summary>
 /// 数据更新前的处理.
 /// </summary>
 /// <param name="data"></param>
 public static void BeforeUpdateOperation(HttpSessionStateBase session, AbstractCommonData data)
 {
     // 更新 最后修改时间.
     data.BeforeUpdateOperation();
 }
Exemplo n.º 18
0
 /// <summary>
 /// 数据插入前的处理.
 /// </summary>
 /// <param name="data"></param>
 public static void BeforeInsertOperation(HttpSessionStateBase session, AbstractCommonData data)
 {
     // 更新插入时间.
     data.BeforeInsertOperation();
 }
Exemplo n.º 19
0
 public void load(AbstractCommonData entity, string cond)
 {
     _abstractDA.load(entity, cond);
 }
Exemplo n.º 20
0
 public void load(AbstractCommonData entity)
 {
     _abstractDA.load(entity);
 }
Exemplo n.º 21
0
 public abstract int delete(AbstractCommonData entity);
Exemplo n.º 22
0
 public abstract int update(AbstractCommonData dataSet);
Exemplo n.º 23
0
 public abstract int add(AbstractCommonData dataSet);
Exemplo n.º 24
0
 public void load(AbstractCommonData entity)
 {
     provider.loadToDataSet(entity);
 }
Exemplo n.º 25
0
 public abstract void loadToDataSet(AbstractCommonData dataSet, string condition, string orderBy, string filledTableName);
Exemplo n.º 26
0
 public int update(AbstractCommonData entity)
 {
     return(provider.update(entity));
 }
Exemplo n.º 27
0
 public abstract void executeSelect(string query, AbstractCommonData entity);
Exemplo n.º 28
0
 public abstract void select(AbstractCommonData entity, string cond);
Exemplo n.º 29
0
 public void load(AbstractCommonData entity, string cond)
 {
     provider.loadToDataSet(entity, cond);
 }
Exemplo n.º 30
0
 public abstract void executeSelect(string query, AbstractCommonData entity, string filledTableName);