Exemple #1
0
        /// <summary>
        /// 连接参数初始化
        /// </summary>
        /// <param name="strConString"></param>
        /// <param name="DataSourceType"></param>
        public dbaFactory( string strConString ,Common.DataSourceType DataSourceType)
        {

            switch (DataSourceType)
            {
                case Common.DataSourceType.SQLServer:

                    m_Connect = new CSQLServerConnect();
                    //数据库连接参数设置
                    m_Connect.strConnectString = strConString;
                    break;

                //case Common.DataSourceType .MySQL:

                //    break;
                //case Common.DataSourceType .Oracle:

                //    break;
                //case Common.DataSourceType .Access:
                //    break;

                //case Common.DataSourceType .TXT:
                //    break;

            }

        }
Exemple #2
0
        /// <summary>
        /// 初始化数据表格样式
        /// </summary>
        /// <param name="ReadOnly"></param>
        protected override void SetIniGridStyle(Common.enumGridStyle style)
        {
            if (m_GridViewUtil.ParentGridView != null)
                GridViewUtil.SetIniGridStyle(m_GridViewUtil.ParentGridView, style);
            if (m_GridViewUtil.ChildGridView != null)
                GridViewUtil.SetIniGridStyle(m_GridViewUtil.ChildGridView, style);

        }
Exemple #3
0
        /// <summary>
        /// 初始化数据表格样式
        /// </summary>
        /// <param name="ReadOnly"></param>
        protected virtual void SetIniGridStyle(Common.enumGridStyle style)
        {

        }
Exemple #4
0
        /// <summary>
        /// 数据重名检查(主键重复)
        /// </summary>
        /// <param name="TableName">数据表名称</param>
        /// <param name="dicItemData">数据内容</param>
        /// <param name="dicPrimarName">主键列名</param>
        /// <param name="strRepFiledName">重名检测列名</param>
        /// <param name="ScanMode">画面模式</param>
        /// <returns></returns>
        public bool GetRepNameCheck(String TableName,
                                     StringDictionary dicItemData,
                                     StringDictionary dicPrimarName,
                                     String strRepFiledName,
                                     Common.DataModifyMode ScanMode)
        {
            bool IsExist = false;
            DataTable dt = new DataTable();
            int rowIndex = 0;
            SqlParameter[] cmdParamters = null;
            SqlParameter SqlParameter = null;

            string w_strWhere = "";
            strRepFiledName = strRepFiledName.ToLower();

            try
            {
                if (dicItemData == null || dicItemData.Count <= 0
                    || dicPrimarName == null || dicPrimarName.Count <= 0
                    || string.IsNullOrEmpty(strRepFiledName) == true) return false;

                string strSql = "SELECT  CAST('0' AS Bit) AS SlctValue," + TableName + ".* "
                             + " FROM " + TableName
                             + " WHERE 1=1 ";

                Common.AdoConnect.Connect.ConnectOpen();

                cmdParamters = new SqlParameter[dicPrimarName.Count + 1];

                foreach (string strKey in dicPrimarName.Keys)
                {
                    if (dicItemData.ContainsKey(strKey) == true && ScanMode == Common.DataModifyMode.upd)
                    {
                        w_strWhere += " AND " + strKey + "<>@" + strKey;

                        SqlParameter = new SqlParameter("@" + strKey, DataFiledType.FiledType[strKey]);
                        SqlParameter.Value = dicItemData[strKey];
                        SqlParameter.Direction = ParameterDirection.Input;
                        cmdParamters[rowIndex] = SqlParameter;
                        rowIndex++;
                    }
                }


               if (dicItemData.ContainsKey(strRepFiledName) == true)
                {
                    w_strWhere += " AND " + strRepFiledName + "=@" + strRepFiledName;

                    SqlParameter = new SqlParameter("@" + strRepFiledName, DataFiledType.FiledType[strRepFiledName]);
                    SqlParameter.Value = dicItemData[strRepFiledName];
                    SqlParameter.Direction = ParameterDirection.Input;
                    cmdParamters[rowIndex] = SqlParameter;
                }

                 strSql += w_strWhere;

                 dt = Common.AdoConnect.Connect.GetDataSet(strSql, cmdParamters);
                if (dt != null)
                {
                    if (dt.Rows.Count > 0)
                        IsExist = true;
                }
                return IsExist;


            }
            catch (Exception ex)
            {
                throw ex;
            }

        }
Exemple #5
0
 public object SetExecuteSP(string StoreProcName, Common.Choose MyChoose, params object[] para)
 {
     throw new Exception("The method or operation is not implemented.");
 }
        /// <summary>
        /// 数据库执行处理
        /// </summary>
        /// <param name="StoreProcName"></param>
        /// <param name="MyChoose"> HasAOutput:仅有单个返回值;
        ///                         OnlyExecSp:仅执行无返回值;
        ///                         RetOneRecord:返回记录集DataTable</param>
        /// <param name="para"></param>
        /// <returns></returns>
        object CBaseConnect.SetExecuteSP(string StoreProcName, Common.Choose MyChoose, params object[] lstParam)
        {
            object RetValue = null;

            SqlCommand ParaCmd;
            object[] w_ParaList;

            try
            {

                if (this.m_SqlConn.State != ConnectionState.Open)
                {
                    this.m_SqlConn.Open();
                }

                if (string.IsNullOrEmpty(StoreProcName) == true)
                {
                    return null;
                }

                ParaCmd = new SqlCommand(StoreProcName, this.m_SqlConn);
                ParaCmd.Transaction = this.Tran;

                ParaCmd.Prepare();
                ParaCmd.CommandTimeout = 300;
                ParaCmd.CommandType = CommandType.StoredProcedure;

                w_ParaList = GetParaToCommand(StoreProcName, lstParam);

                for (int paraIndex = 0; w_ParaList != null && paraIndex < w_ParaList.Length; paraIndex++)
                {
                    if (w_ParaList[paraIndex] != null)
                        ParaCmd.Parameters.Add(w_ParaList[paraIndex]);
                }

                switch (MyChoose)
                {
                    case Common.Choose.HasAOutput:

                        //有一个返回值,但定义是最后一个参数
                        ParaCmd.ExecuteNonQuery();
                        RetValue = ParaCmd.Parameters[ParaCmd.Parameters.Count - 1].Value;
                        break;

                    case Common.Choose.OnlyExecSp:

                        //仅仅进行数据处理,无返回值。  
                        ParaCmd.ExecuteNonQuery();
                        RetValue = 0;
                        break;

                    case Common.Choose.RetOneRecord:

                        //返回一个SqlDataReader。
                        RetValue = GetConvertDataReaderToDataTable(ParaCmd.ExecuteReader(CommandBehavior.Default));
                        break;
                    //Anjie,2012-1-9,新增方法,用于可返回多表结果集DataSet
                    case Common.Choose.RetMultiTable:
                        RetValue = ExecuteDataset(ParaCmd, null, (SqlParameter[])lstParam);
                        break;
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }

            return RetValue;
        }
Exemple #7
0
 public bool GetRepNameCheck(string TableName, StringDictionary dicItemData, StringDictionary dicPrimarName, string strRepFiledName, Common.DataModifyMode ScanMode)
 {
     throw new Exception("The method or operation is not implemented.");
 }
Exemple #8
0
        /// <summary>
        /// 设定工具栏的有效性
        /// </summary>
        /// <param name="mode">编辑的状态</param>
        public static void SetCmdControl(Common.DataModifyMode mode, frmBaseToolXC frmbase, int RecordCount)
        {
            try
            {
                if (mode == Common.DataModifyMode.dsp)  //如果是查看
                {
                    frmbase.NewButtonEnabled = true;
                    frmbase.PrintButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = true;
                    frmbase.SaveButtonEnabled = false;
                    frmbase.CancelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = true;
                    frmbase.DeleteButtonEnabled = true;
                    frmbase.EditButtonEnabled = true;

                    if (RecordCount == 0)
                    {

                        frmbase.PrintButtonEnabled = false;
                        frmbase.ExcelButtonEnabled = false;
                        frmbase.ImportButtonEnabled = false;
                        frmbase.SearchButtonEnabled = false;
                        frmbase.SaveButtonEnabled = false;
                        frmbase.CancelButtonEnabled = false;
                        frmbase.EditButtonEnabled = false;
                        frmbase.DeleteButtonEnabled = false;

                    }
                }
                else
                {
                    frmbase.NewButtonEnabled = false;
                    frmbase.PrintButtonEnabled = false;
                    frmbase.ImportButtonEnabled = false;
                    frmbase.SaveButtonEnabled = true;
                    frmbase.CancelButtonEnabled = true;
                    frmbase.ExcelButtonEnabled = false;
                    frmbase.SearchButtonEnabled = false;
                    frmbase.EditButtonEnabled = false;
                    frmbase.DeleteButtonEnabled = false;

                }
            }
            catch (Exception ex)
            {
                XtraMsgBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemple #9
0
        /// <summary>
        /// 初始化数据表格样式
        /// </summary>
        /// <param name="ListView">表格中的ListView对象</param>
        /// <param name="style">表格显示模式</param>
        public static void SetIniGridStyle(DevExpress.XtraGrid.Views.Grid.GridView ListView, Common.enumGridStyle style)
        {

            //设定小数位数
            for (int i = 0; i < ListView.Columns.Count; i++)
            {
                //if (ListView.Columns[i].ColumnType.ToString() == "System.Decimal")
                //{
                //    //ListView.Columns[i].SummaryItem.DisplayFormat = "{0:c}";
                //    ListView.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                //    ListView.Columns[i].DisplayFormat.FormatString = "n4";
                //    ListView.Columns[i].AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                //    ListView.Columns[i].AppearanceHeader.Options.UseTextOptions = true;
                //设置自动筛选行默认条件为包含(%条件%)
                ListView.Columns[i].OptionsFilter.AutoFilterCondition = DevExpress.XtraGrid.Columns.AutoFilterCondition.Contains;
            }

            //common._sysrun.CurRowBackcolor = Color.WhiteSmoke;
            ListView.IndicatorWidth = 45;

            switch (style)
            {
                case Common.enumGridStyle.ViewStyle:
                    ListView.OptionsView.ColumnAutoWidth = false;
                    ListView.OptionsView.EnableAppearanceEvenRow = false;
                    ListView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
                    ListView.Appearance.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                    ListView.Appearance.FocusedRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.FocusedRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.FocusedRow.ForeColor = Color.Black;

                    ListView.Appearance.SelectedRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.SelectedRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.SelectedRow.ForeColor = Color.Black;

                    ListView.Appearance.HideSelectionRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.HideSelectionRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.Black;
                    //ListView.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always;
                    //ListView.VertScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Always;
                    //ListView.Appearance.OddRow.BackColor = System.Drawing.Color.White;
                    //ListView.Appearance.OddRow.BackColor2 = System.Drawing.Color.White;

                    //ListView.Appearance.EvenRow.BackColor = System.Drawing.Color.WhiteSmoke;
                    //ListView.Appearance.EvenRow.BackColor2 = System.Drawing.Color.WhiteSmoke;


                    //ListView.Appearance.HideSelectionRow.BackColor = System.Drawing.Color.Beige;
                    //ListView.Appearance.HideSelectionRow.BackColor2 = System.Drawing.Color.Beige;
                    //ListView.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.Black;
                    for (int col = 0; col < ListView.Columns.Count; col++)
                    {
                        ListView.Columns[col].OptionsColumn.AllowEdit = false;
                        ListView.Columns[col].OptionsColumn.AllowFocus = true;


                    }


                    break;

                case Common.enumGridStyle.InputStyle:

                    //ListView.OptionsBehavior.Editable = true;

                    // 默认当单击单元格或进入单元格时,选中单元格内容
                    ListView.OptionsBehavior.AutoSelectAllInEditor = true;
                    // 自动建立列
                    ListView.OptionsBehavior.AutoPopulateColumns = true;

                    //View Options选项
                    //默认显示过滤面板,即当Header能定制过滤,是否显示过滤面板
                    ListView.OptionsFilter.ShowAllTableValuesInFilterPopup = true;
                    // 默认不显示分组面板
                    ListView.OptionsView.ShowGroupPanel = false;
                    // 默认显示指示器
                    ListView.OptionsView.ShowIndicator = true;
                    // 默认显示列的总宽度和视图的宽度不相等
                    ListView.OptionsView.ColumnAutoWidth = false;
                    // 默认显示视图脚
                    //ListView.OptionsView.ShowFooter =true ;

                    // Print Options选项
                    // 不能自动宽度
                    ListView.OptionsPrint.AutoWidth = false;

                    // Cell Navigation Options选项
                    // 按Enter进入下一列
                    ListView.OptionsNavigation.EnterMoveNextColumn = true;

                    for (int col = 0; col < ListView.Columns.Count; col++)
                    {
                        ListView.Columns[col].OptionsColumn.AllowEdit = true;
                        ListView.Columns[col].OptionsColumn.AllowFocus = true;

                    }

                    // 焦点自动到新行
                    ListView.OptionsNavigation.AutoFocusNewRow = true;
                    ListView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.CellFocus;

                    //ListView.OptionsView.NewItemRowPosition = DevExpress.XtraGrid.Views.Grid.NewItemRowPosition.Bottom;

                    ListView.Appearance.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;

                    //ListView.Appearance.FocusedRow.BackColor = System.Drawing.Color.White;
                    //ListView.Appearance.FocusedRow.BackColor2 = System.Drawing.Color.White;
                    //ListView.Appearance.FocusedRow.ForeColor = Color.Black;

                    //ListView.Appearance.SelectedRow.BackColor = System.Drawing.Color.White;
                    //ListView.Appearance.SelectedRow.BackColor2 = System.Drawing.Color.White;
                    //ListView.Appearance.SelectedRow.ForeColor = Color.Black;

                    //ListView.Appearance.FocusedCell.BackColor = System.Drawing.Color.White;
                    //ListView.Appearance.FocusedCell.ForeColor = System.Drawing.Color.Black;

                    break;

                default:

                    //StyleFormatCondition styleCondition = new StyleFormatCondition();
                    //ListView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.None;
                    //ListView.OptionsSelection.EnableAppearanceFocusedRow = false;
                    //ListView.OptionsSelection.EnableAppearanceFocusedCell = false;
                    //ListView
                    //// Adds the style condition to the collection
                    //ListView.FormatConditions.Add(styleCondition);
                    //styleCondition.Value1 = 0;
                    //styleCondition.Value2 = 0;
                    //// Modifying the appearance settings
                    //styleCondition.Appearance.BackColor = Color.White;
                    //styleCondition.Appearance.Font = new Font(ListView.Appearance.Row.Font, FontStyle.Bold);
                    //styleCondition.Appearance.ForeColor = Color.White;
                    //styleCondition.Condition = FormatConditionEnum.Equal;
                    //styleCondition.ApplyToRow = false;

                    ListView.FocusRectStyle = DevExpress.XtraGrid.Views.Grid.DrawFocusRectStyle.RowFocus;
                    ListView.Appearance.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Center;
                    ListView.Appearance.FocusedRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.FocusedRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.FocusedRow.ForeColor = Color.Black;

                    ListView.Appearance.SelectedRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.SelectedRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.SelectedRow.ForeColor = Color.Black;

                    ListView.Appearance.HideSelectionRow.BackColor = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.HideSelectionRow.BackColor2 = Common._sysrun.CurRowBackcolor;
                    ListView.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.Black;

                    ListView.OptionsView.ColumnAutoWidth = false;
                    ListView.OptionsView.EnableAppearanceEvenRow = false;
                    ListView.IndicatorWidth = 45;
                    ListView.HorzScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
                    ListView.VertScrollVisibility = DevExpress.XtraGrid.Views.Base.ScrollVisibility.Auto;
                    for (int col = 0; col < ListView.Columns.Count; col++)
                    {
                        ListView.Columns[col].OptionsColumn.AllowEdit = false;
                        ListView.Columns[col].OptionsColumn.AllowFocus = true;

                    }
                    //ListView.Appearance.OddRow.BackColor = System.Drawing.Color.White;
                    //ListView.Appearance.OddRow.BackColor2 = System.Drawing.Color.White;

                    //ListView.Appearance.EvenRow.BackColor = System.Drawing.Color.WhiteSmoke;
                    //ListView.Appearance.EvenRow.BackColor2 = System.Drawing.Color.WhiteSmoke;

                    //ListView.Appearance.FocusedRow.BackColor = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.FocusedRow.BackColor2 = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.FocusedRow.ForeColor = Color.White;

                    //ListView.Appearance.SelectedRow.BackColor = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.SelectedRow.BackColor2 = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.SelectedRow.ForeColor = Color.White;

                    //ListView.Appearance.HideSelectionRow.BackColor = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.HideSelectionRow.BackColor2 = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.White;

                    //ListView.Appearance.HideSelectionRow.BackColor = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.HideSelectionRow.BackColor2 = System.Drawing.Color.RoyalBlue;
                    //ListView.Appearance.HideSelectionRow.ForeColor = System.Drawing.Color.White;

                    ListView.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                    ListView.Appearance.HeaderPanel.Options.UseTextOptions = true;
                    ListView.OptionsView.RowAutoHeight = false;
                    ListView.ColumnPanelRowHeight = 30;
                    ////设定小数位数
                    //for (int i = 0; i < ListView.Columns.Count; i++)
                    //{
                    //    if (ListView.Columns[i].ColumnType.ToString() == "System.Decimal")
                    //    {
                    //        //ListView.Columns[i].SummaryItem.DisplayFormat = "{0:c}";
                    //        ListView.Columns[i].DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
                    //        ListView.Columns[i].DisplayFormat.FormatString = "f1";
                    //        ListView.Columns[i].AppearanceHeader.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
                    //        ListView.Columns[i].AppearanceHeader.Options.UseTextOptions = true;
                    //    }

                    //}
                    break;
            }

        }