Example #1
0
        /// <summary>
        /// 设置行的默认值
        /// </summary>
        /// <param name="dr"></param>
        /// <param name="paraDefaultValue"></param>
        public static void SetDataRowDefaultValue(DataRow dr, JArray paraDefaultValue)
        {
            //dtMasterNew.Clear();
            if (paraDefaultValue != null)
            {
                dr.BeginEdit();
                foreach (var par in paraDefaultValue)
                {
                    string FieldName = par["FieldName"].ToString();
                    string Value     = par["DefaultValue"].ToString();
                    if (dr.Table.Columns.Contains(FieldName) && Value != string.Empty)
                    {
                        if (dr.Table.Columns[FieldName].DataType == Type.GetType("System.DateTime"))
                        {
                            dr[FieldName] = RFBase.GetServerDateTime().AddDays(int.Parse(Value));
                        }
                        else
                        {
                            dr[FieldName] = Value;
                        }
                    }
                }
                dr.EndEdit();
            }

            //dt.RejectChanges();
        }
Example #2
0
        public void SetParameter(string paramName, string ParamType, object val)
        {
            if (val == null)
            {
                val = DBNull.Value;
            }

            if (paras.ContainsKey(paramName))//先删除原参数再增加
            {
                RemoveParameter(paramName);
            }

            paras[paramName]       = new SqlParameter(paramName, RFBase.GetSqlDbType(ParamType));
            paras[paramName].Value = val;
        }
Example #3
0
        public int ExpectedRows;     //返回行数


        public void DoValidate(Dictionary <string, SqlParameter> paras, RFBase rfbase)
        {
            if (InterActive)
            {
                //object v = FrmBase.Bss_Helper.GetValue(Sql, CommandType.Text, paras.Values.ToArray());
                //frmbase.SetParameter(AffectedParam, v);//以后需要扩展,通过DS返回多个参数值,目前AffectedParam只支持单个参数
                DataSet ds = RFBase.Bss_Helper.GetDataSet_SQL(Sql, paras.Values.ToArray());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    //处理返回参数
                    for (var n = 0; n < ds.Tables[0].Columns.Count; n++)
                    {
                        rfbase.SetParameter(ds.Tables[0].Columns[n].ToString(), ds.Tables[0].Rows[0][n]);
                    }
                }
            }
            else
            {
                //FrmBase.Bss_Helper.ExcuteCmd(Sql, CommandType.Text, paras.Values.ToArray());
                // 增加了加入返回行数控制
                int RowCount = RFBase.Bss_Helper.ExcuteCmd(Sql, CommandType.Text, paras.Values.ToArray());
                if (ExpectedRows != 0 && ExpectedRows != RowCount)
                {
                    throw new RFException("数据可能已被其它用户修改,请刷新重试!");
                }
            }
            //if (InterActive)
            //{
            //    object v = RFBase.Bss_Helper.GetValue(Sql, CommandType.Text, paras.Values.ToArray());
            //    rfbase.SetParameter(AffectedParam, v);
            //}
            //else
            //{
            //    RFBase.Bss_Helper.ExcuteCmd(Sql, CommandType.Text, paras.Values.ToArray());
            //}
        }