Example #1
0
        public bool IsExistRecord(string key1, string key2, string value)
        {
            bool   isExist     = false;
            string sqlString   = string.Empty;
            object valueObject = null;

            sqlString  = "SELECT COUNT(1) FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()] + this._newLineSybm;
            sqlString += " WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + key1.Replace("'", "''").Trim() + "'" + this._newLineSybm;
            sqlString += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + "='" + key2.Replace("'", "''").Trim() + "'" + this._newLineSybm;
            //sqlString += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCValue.ToString()] + "='" + value.Replace("'", "''").Trim() + "'" + this._newLineSybm;

            DataBaseCommand <CodeMasterInfo> dataBaseCommand = new DataBaseCommand <CodeMasterInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;

            if (count > 0)
            {
                isExist = true;
            }

            return(isExist);
        }
Example #2
0
        /// <summary>
        ///     移除主机
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdRemoveHost_Click(object sender, EventArgs e)
        {
            //使用修改系统数据集和repleSetReconfig
            MongoCollection replsetCol = RuntimeMongoDbContext.GetCurrentServer().
                                         GetDatabase(ConstMgr.DatabaseNameLocal).GetCollection("system.replset");
            var replsetDoc = replsetCol.FindOneAs <BsonDocument>();
            var memberlist = replsetDoc.GetElement("members").Value.AsBsonArray;
            var strHost    = lstHost.SelectedItem.ToString();

            for (var i = 0; i < memberlist.Count; i++)
            {
                if (memberlist[i].AsBsonDocument.GetElement("host").Value.ToString() != strHost)
                {
                    continue;
                }
                memberlist.RemoveAt(i);
                break;
            }
            try
            {
                DataBaseCommand.ReconfigReplsetServer(RuntimeMongoDbContext.GetCurrentServer(), replsetDoc);
                //由于这个命令会触发异常,所以没有Result可以获得
                RuntimeMongoDbContext.CurrentMongoConnectionconfig.ReplsetList.Remove(strHost);
                lstHost.Items.Remove(lstHost.SelectedItem);
                Operater.RefreshConnectionConfig(RuntimeMongoDbContext.CurrentMongoConnectionconfig);
                MyMessageBox.ShowMessage("Remove Memeber OK", "Please refresh connection after one minute.");
            }
            catch (Exception ex)
            {
                Utility.ExceptionDeal(ex);
            }
        }
        /// <summary>
        ///     增加分片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdAddSharding_Click(object sender, EventArgs e)
        {
            var lstAddress = new List <string>();

            foreach (string item in lstHost.Items)
            {
                lstAddress.Add(item.Trim());
            }
            var           resultlst = new List <CommandResult>();
            CommandResult result;

            if (chkAdvance.Checked)
            {
                result = DataBaseCommand.AddSharding(_prmSvr, txtReplsetName.Text, lstAddress, txtName.Text,
                                                     NumMaxSize.Value);
            }
            else
            {
                result = DataBaseCommand.AddSharding(_prmSvr, txtReplsetName.Text, lstAddress, string.Empty, 0);
            }
            resultlst.Add(result);
            MyMessageBox.ShowMessage("Add Sharding", "Result:" + (result.Ok ? "OK" : "Fail"),
                                     MongoHelper.ConvertCommandResultlstToString(resultlst));
            lstSharding.Items.Clear();
            foreach (var lst in Operater.GetShardInfo(_prmSvr, "_id"))
            {
                lstSharding.Items.Add(lst.Value);
            }
            lstHost.Items.Clear();
        }
Example #4
0
        public bool IsExistRecord(string userID)
        {
            bool   isExist     = false;
            string sqlString   = string.Empty;
            object valueObject = null;

            sqlString  = "SELECT COUNT(1) FROM " + this._dataBaseDic[UserInformationInfoEnum.TableName.ToString()] + this._newLineSybm;
            sqlString += " WHERE " + this._dataBaseDic[UserInformationInfoEnum.UsmCUserID.ToString()] + "='" + userID.Replace("'", "''").Trim() + "'";

            DataBaseCommand <UserInformationInfo> dataBaseCommand = new DataBaseCommand <UserInformationInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;

            if (count > 0)
            {
                isExist = true;
            }

            return(isExist);
        }
Example #5
0
        public bool IsExistRecord(string clientNum)
        {
            bool   isExist     = false;
            string sqlString   = string.Empty;
            object valueObject = null;

            sqlString  = "SELECT COUNT(1) FROM ClientMaster_clm" + Environment.NewLine;
            sqlString += " WHERE clm_cClientNum='" + clientNum.Trim().Replace("'", "''") + "'";

            DataBaseCommand <ClientMasterInfo> dataBaseCommand = new DataBaseCommand <ClientMasterInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;

            if (count > 0)
            {
                isExist = true;
            }

            return(isExist);
        }
Example #6
0
        /// <summary>
        ///     Add A Custom User
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddCustomRole_Click(object sender, EventArgs e)
        {
            var r = new Role();

            if (RuntimeMongoDbContext.GetCurrentDataBase() != null)
            {
                r.Database = RuntimeMongoDbContext.GetCurrentDataBase().Name;
            }
            else
            {
                r.Database = ConstMgr.DatabaseNameAdmin;
            }
            r.Rolename   = txtRolename.Text;
            r.Privileges = new Role.Privilege[_privilegeList.Count];
            for (var i = 0; i < _privilegeList.Count; i++)
            {
                r.Privileges[i] = _privilegeList[i];
            }
            r.Roles = new Role.GrantRole[_roleList.Count];
            for (var i = 0; i < _roleList.Count; i++)
            {
                r.Roles[i] = _roleList[i];
            }
            //这个时候可能没有GetCurrentDataBase,如果是Admin
            var result = DataBaseCommand.createRole(RuntimeMongoDbContext.GetCurrentServer().GetDatabase(r.Database), r);

            if (result.Ok)
            {
                MyMessageBox.ShowEasyMessage("Succeed", "Add Role OK");
            }
            else
            {
                MyMessageBox.ShowMessage("Error", "Add Role Error", result.Response.ToString());
            }
        }
        /// <summary>
        ///     分片配置(数据库)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdEnableSharding_Click(object sender, EventArgs e)
        {
            var resultlst = new List <CommandResult> {
                DataBaseCommand.EnableSharding(_prmSvr, cmbDataBase.Text)
            };

            MyMessageBox.ShowMessage("EnableSharding", "Result",
                                     MongoHelper.ConvertCommandResultlstToString(resultlst));
        }
        /// <summary>
        ///     为Sharding增加Zone(Tag)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddShardZone_Click(object sender, EventArgs e)
        {
            var resultlst = new List <CommandResult>
            {
                DataBaseCommand.AddShardToZone(_prmSvr, cmbShard.Text, txtShardZone.Text)
            };

            MyMessageBox.ShowMessage("Add Shard Zone", "Result", MongoHelper.ConvertCommandResultlstToString(resultlst));
            RefreshShardingZone();
        }
        /// <summary>
        ///     分片配置(数据集)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdShardCollectionSharding_Click(object sender, EventArgs e)
        {
            var          resultlst = new List <CommandResult>();
            var          result    = _prmSvr.GetDatabase(cmbDataBase.Text).GetCollection(cmbCollection.Text).GetIndexes();
            BsonDocument indexDoc  = result[cmbIndexList.SelectedIndex].Key;

            resultlst.Add(DataBaseCommand.ShardCollection(_prmSvr, cmbDataBase.Text + "." + cmbCollection.Text, indexDoc));
            MyMessageBox.ShowMessage("EnableSharding", "Result",
                                     MongoHelper.ConvertCommandResultlstToString(resultlst));
        }
Example #10
0
        void ExecuteCommand()
        {
            DataBaseCommand Command = (DataBaseCommand)Argums.Dequeue();

            switch (Command)
            {
            case DataBaseCommand.Add:
                if (Invoke != null)
                {
                    Invoke((Action) delegate { base.Add((Book)Argums.Dequeue()); });
                }
                else
                {
                    base.Add((Book)Argums.Dequeue());
                }
                break;

            case DataBaseCommand.RemoveAt:
                if (Invoke != null)
                {
                    Invoke((Action) delegate { base.RemoveAt((int)Argums.Dequeue()); });
                }
                else
                {
                    base.RemoveAt((int)Argums.Dequeue());
                }
                break;

            case DataBaseCommand.Change:
                int index = (int)Argums.Dequeue();
                if (Invoke != null)
                {
                    /*Invoke((Action)delegate { base.SetItem((int)Argums.Dequeue(), (Book)Argums.Dequeue()); });*/
                    Invoke((Action) delegate { base.RemoveAt(index); });
                    Invoke((Action) delegate { base.Insert(index, (Book)Argums.Dequeue()); });
                }
                else
                {
                    base.SetItem((int)Argums.Dequeue(), (Book)Argums.Dequeue());
                }
                break;

            case DataBaseCommand.Clear:
                if (Invoke != null)
                {
                    Invoke((Action) delegate { base.Clear(); });
                }
                else
                {
                    base.Clear();
                }
                break;
            }
        }
        /// <summary>
        ///     Add Zone Range
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdaddZoneRange_Click(object sender, EventArgs e)
        {
            var resultlst = new List <CommandResult>
            {
                DataBaseCommand.updateZoneKeyRange(_prmSvr, cmbShardKeyDB.Text + "." + cmbShardKeyCol.Text, cmbField.Text, ctlBsonValueShardKeyFrom.GetValue(),
                                                   ctlBsonValueShardKeyTo.GetValue(), cmbTagList.Text.Split(".".ToCharArray())[1])
            };

            MyMessageBox.ShowMessage("Add Shard Tag", "Result",
                                     MongoHelper.ConvertCommandResultlstToString(resultlst));
            RefreshShardingRange();
        }
Example #12
0
        public List <UserInformationInfo> FindRecord(UserInformationFindInfo userInformationFindInfo)
        {
            string sqlString = string.Empty;
            string sqlWhere  = string.Empty;

            if (userInformationFindInfo == null)
            {
                return(null);
            }

            sqlWhere = " WHERE 1=1 ";
            if (userInformationFindInfo.UsmCUserID.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCUserID.ToString()] + "='" + userInformationFindInfo.UsmCUserID.Replace("'", "''") + "'";
            }
            if (userInformationFindInfo.UsmCEngName.Trim() != "")
            {
                string symbol = "=";
                if (userInformationFindInfo.UsmCEngNameIsLike)
                {
                    symbol = "LIKE";
                }
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCEngName.ToString()] + symbol + " '" + userInformationFindInfo.UsmCEngName.Replace("'", "''") + "'";
            }

            if (userInformationFindInfo.UsmCChaName.Trim() != "")
            {
                string symbol = "=";
                if (userInformationFindInfo.UsmCChaNameIsLike)
                {
                    symbol = "LIKE";
                }
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCChaName.ToString()] + symbol + " '" + userInformationFindInfo.UsmCChaName.Replace("'", "''") + "'";
            }

            sqlString = "SELECT * FROM " + UserInformationInfoEnum.TableName.ToString() + sqlWhere;

            DataBaseCommand <UserInformationInfo> dbCommand = new DataBaseCommand <UserInformationInfo>();
            List <UserInformationInfo>            userInformationInfoList = null;

            try
            {
                //userInformationInfoList = dbCommand.GetRecordList(sqlString, DataBaseDictionary.Instance.GetUserInformationDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(userInformationInfoList);
        }
Example #13
0
        public List<UserInformationInfo> FindRecord(UserInformationFindInfo userInformationFindInfo)
        {
            string sqlString = string.Empty;
            string sqlWhere = string.Empty;

            if (userInformationFindInfo == null)
            {
                return null;
            }

            sqlWhere = " WHERE 1=1 ";
            if (userInformationFindInfo.UsmCUserID.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCUserID.ToString()] + "='" + userInformationFindInfo.UsmCUserID.Replace("'", "''") + "'";
            }
            if (userInformationFindInfo.UsmCEngName.Trim() != "")
            {
                string symbol = "=";
                if (userInformationFindInfo.UsmCEngNameIsLike)
                {
                    symbol = "LIKE";
                }
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCEngName.ToString()] + symbol + " '" + userInformationFindInfo.UsmCEngName.Replace("'", "''") + "'";
            }

            if (userInformationFindInfo.UsmCChaName.Trim() != "")
            {
                string symbol = "=";
                if (userInformationFindInfo.UsmCChaNameIsLike)
                {
                    symbol = "LIKE";
                }
                sqlWhere += " AND " + this._dataBaseDic[UserInformationInfoEnum.UsmCChaName.ToString()] + symbol + " '" + userInformationFindInfo.UsmCChaName.Replace("'", "''") + "'";
            }

            sqlString = "SELECT * FROM " + UserInformationInfoEnum.TableName.ToString() + sqlWhere;

            DataBaseCommand<UserInformationInfo> dbCommand = new DataBaseCommand<UserInformationInfo>();
            List<UserInformationInfo> userInformationInfoList=null;

            try
            {
                //userInformationInfoList = dbCommand.GetRecordList(sqlString, DataBaseDictionary.Instance.GetUserInformationDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return userInformationInfoList;
        }
 /// <summary>
 ///     移除Sharding
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void cmdRemoveSharding_Click(object sender, EventArgs e)
 {
     foreach (string item in lstSharding.SelectedItems)
     {
         var resultlst = new List <CommandResult> {
             DataBaseCommand.RemoveSharding(_prmSvr, item)
         };
         MyMessageBox.ShowMessage("Remove Sharding", "Result",
                                  MongoHelper.ConvertCommandResultlstToString(resultlst));
     }
     lstSharding.Items.Clear();
     foreach (var lst in Operater.GetShardInfo(_prmSvr, "_id"))
     {
         lstSharding.Items.Add(lst.Value);
     }
 }
Example #15
0
        /// <summary>
        ///     Run Aggregate
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdRun_Click(object sender, EventArgs e)
        {
            if (stages.Count <= 0)
            {
                return;
            }
            var mCommandResult = DataBaseCommand.Aggregate(stages, RuntimeMongoDbContext.GetCurrentCollection().Name);

            if (mCommandResult.Ok)
            {
                trvResult.DatatreeView.BeginUpdate();
                UiHelper.FillDataToTreeView("Aggregate Result", trvResult, mCommandResult.Response);
                trvResult.DatatreeView.ExpandAll();
                trvResult.DatatreeView.EndUpdate();
            }
            else
            {
                MyMessageBox.ShowMessage("Aggregate Result", mCommandResult.ErrorMessage);
            }
        }
Example #16
0
        public List <Model.Master.DeptMasterInfo> GetAllRecord()
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + this._newLineSybm;

            DataBaseCommand <DeptMasterInfo> dbCommand = new DataBaseCommand <DeptMasterInfo>();
            List <DeptMasterInfo>            deptMasterInfoList;

            try
            {
                deptMasterInfoList = dbCommand.GetRecordList(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(deptMasterInfoList);
        }
        /// <summary>
        ///     ConvertToCapped
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ConvertToCappedtoolStripMenuItem_Click(object sender, EventArgs e)
        {
            var maxSize = MyMessageBox.ShowInput("Please Input MaxSize(Byte)", "MaxSize", "4096");

            if (string.IsNullOrEmpty(maxSize))
            {
                return;
            }
            if (long.TryParse(maxSize, out long lngMaxSize))
            {
                var colName = RuntimeMongoDbContext.GetCurrentCollectionName();
                var db      = RuntimeMongoDbContext.GetCurrentDataBase();
                var result  = DataBaseCommand.convertToCapped(colName, lngMaxSize, db);
                MyMessageBox.ShowEasyMessage("ConvertToCapped", result.Response.ToString());
            }
            else
            {
                MessageBox.Show("Please Input a Number");
            }
        }
Example #18
0
        public CodeMasterInfo DisplayRecord(IModelObject KeyObject)
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM CodeMaster_cmt WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtIRecID.ToString()] + "=" + KeyObject.RecordID.ToString();

            DataBaseCommand<CodeMasterInfo> dbCommand = new DataBaseCommand<CodeMasterInfo>();
            CodeMasterInfo codeMaster=null;

            try
            {
                //codeMaster = dbCommand.GetRecord(sqlString, DataBaseDictionary.Instance.GetCodeMasterDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return codeMaster;
        }
Example #19
0
        public CodeMasterInfo DisplayRecord(IModelObject KeyObject)
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM CodeMaster_cmt WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtIRecID.ToString()] + "=" + KeyObject.RecordID.ToString();

            DataBaseCommand <CodeMasterInfo> dbCommand = new DataBaseCommand <CodeMasterInfo>();
            CodeMasterInfo codeMaster = null;

            try
            {
                //codeMaster = dbCommand.GetRecord(sqlString, DataBaseDictionary.Instance.GetCodeMasterDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(codeMaster);
        }
Example #20
0
        public Model.Master.DeptMasterInfo DisplayRecord(IModelObject KeyObject)
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM "+this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()]+Environment.NewLine;
            sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.RecordID.ToString()] + "=" + KeyObject.RecordID.ToString();

            DataBaseCommand<DeptMasterInfo> dbCommand = new DataBaseCommand<DeptMasterInfo>();
            DeptMasterInfo deptMasterInfo;

            try
            {
                deptMasterInfo = dbCommand.GetRecord(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return deptMasterInfo;
        }
Example #21
0
        public DeptMasterInfo GetRecord(string deptNum)
        {
            string sqlString = string.Empty;

            sqlString  = "SELECT * FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + Environment.NewLine;
            sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.DpmCDeptNumber.ToString()] + "='" + deptNum.Replace("'", "''") + "'";

            DataBaseCommand <DeptMasterInfo> dbCommand = new DataBaseCommand <DeptMasterInfo>();
            DeptMasterInfo deptMasterInfo;

            try
            {
                deptMasterInfo = dbCommand.GetRecord(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(deptMasterInfo);
        }
Example #22
0
        public List <CodeMasterInfo> GetKey1s()
        {
            string sqlString = string.Empty;
            List <CodeMasterInfo>            codeMasterList;
            DataBaseCommand <CodeMasterInfo> dbCommand = new DataBaseCommand <CodeMasterInfo>();

            sqlString = LocalLayer.LocalDefine.Instance.GetInitComboBoxSQL(this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()], this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()], "");
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add(CodeMasterInfoEnum.CmtCKey1.ToString(), this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()]);
            try
            {
                codeMasterList = dbCommand.GetRecordList(sqlString, dic);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(codeMasterList);
        }
Example #23
0
        public Model.Master.DeptMasterInfo DisplayRecord(IModelObject KeyObject)
        {
            string sqlString = string.Empty;

            sqlString  = "SELECT * FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + Environment.NewLine;
            sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.RecordID.ToString()] + "=" + KeyObject.RecordID.ToString();

            DataBaseCommand <DeptMasterInfo> dbCommand = new DataBaseCommand <DeptMasterInfo>();
            DeptMasterInfo deptMasterInfo;

            try
            {
                deptMasterInfo = dbCommand.GetRecord(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(deptMasterInfo);
        }
Example #24
0
        public List <CodeMasterInfo> FindRecord(CodeMasterFindInfo codeMasterFindInfo)
        {
            string sqlString = string.Empty;
            string sqlWhere  = string.Empty;

            if (codeMasterFindInfo == null)
            {
                return(null);
            }

            sqlWhere = " WHERE 1=1 ";
            if (codeMasterFindInfo.CmtCKey1.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + codeMasterFindInfo.CmtCKey1.Replace("'", "''") + "'";
            }
            if (codeMasterFindInfo.CmtCKey2.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + "='" + codeMasterFindInfo.CmtCKey2.Replace("'", "''") + "'";
            }
            if (codeMasterFindInfo.CmtCValue.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCValue.ToString()] + "='" + codeMasterFindInfo.CmtCValue.Replace("'", "''") + "'";
            }

            sqlString = "SELECT * FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()] + sqlWhere;

            DataBaseCommand <CodeMasterInfo> dbCommand      = new DataBaseCommand <CodeMasterInfo>();
            List <CodeMasterInfo>            codeMasterList = null;

            try
            {
                //codeMasterList = dbCommand.GetRecordList(sqlString, DataBaseDictionary.Instance.GetCodeMasterDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(codeMasterList);
        }
Example #25
0
        public List <CodeMasterInfo> GetKey2s(string key1)
        {
            string sqlString = string.Empty;
            List <CodeMasterInfo>            codeMasterList;
            DataBaseCommand <CodeMasterInfo> dbCommand = new DataBaseCommand <CodeMasterInfo>();

            sqlString  = "SELECT DISTINCT " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + " FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()];
            sqlString += " WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + key1.Replace("'", "''") + "'";

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add(CodeMasterInfoEnum.CmtCKey2.ToString(), this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()]);
            try
            {
                codeMasterList = dbCommand.GetRecordList(sqlString, dic);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return(codeMasterList);
        }
Example #26
0
        public List<CodeMasterInfo> FindRecord(CodeMasterFindInfo codeMasterFindInfo)
        {
            string sqlString = string.Empty;
            string sqlWhere = string.Empty;

            if (codeMasterFindInfo == null)
            {
                return null;
            }

            sqlWhere = " WHERE 1=1 ";
            if (codeMasterFindInfo.CmtCKey1.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + codeMasterFindInfo.CmtCKey1.Replace("'", "''") + "'";
            }
            if (codeMasterFindInfo.CmtCKey2.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + "='" + codeMasterFindInfo.CmtCKey2.Replace("'", "''") + "'";
            }
            if (codeMasterFindInfo.CmtCValue.Trim() != "")
            {
                sqlWhere += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCValue.ToString()] + "='" + codeMasterFindInfo.CmtCValue.Replace("'", "''") + "'";
            }

            sqlString = "SELECT * FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()] + sqlWhere;

            DataBaseCommand<CodeMasterInfo> dbCommand = new DataBaseCommand<CodeMasterInfo>();
            List<CodeMasterInfo> codeMasterList=null;

            try
            {
                //codeMasterList = dbCommand.GetRecordList(sqlString, DataBaseDictionary.Instance.GetCodeMasterDBD());
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return codeMasterList;
        }
Example #27
0
        public bool IsExistRecord(string key1, string key2, string value)
        {
            bool isExist = false;
            string sqlString = string.Empty;
            object valueObject = null;

            sqlString = "SELECT COUNT(1) FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()] + this._newLineSybm;
            sqlString += " WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + key1.Replace("'", "''").Trim() + "'" + this._newLineSybm;
            sqlString += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + "='" + key2.Replace("'", "''").Trim() + "'" + this._newLineSybm;
            //sqlString += " AND " + this._dataBaseDic[CodeMasterInfoEnum.CmtCValue.ToString()] + "='" + value.Replace("'", "''").Trim() + "'" + this._newLineSybm;

            DataBaseCommand<CodeMasterInfo> dataBaseCommand = new DataBaseCommand<CodeMasterInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;
            if (count > 0)
            {
                isExist = true;
            }

            return isExist;
        }
Example #28
0
        public List<CodeMasterInfo> GetKey2s(string key1)
        {
            string sqlString = string.Empty;
            List<CodeMasterInfo> codeMasterList;
            DataBaseCommand<CodeMasterInfo> dbCommand = new DataBaseCommand<CodeMasterInfo>();

            sqlString = "SELECT DISTINCT " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()] + " FROM " + this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()];
            sqlString += " WHERE " + this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()] + "='" + key1.Replace("'", "''") + "'";

            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add(CodeMasterInfoEnum.CmtCKey2.ToString(), this._dataBaseDic[CodeMasterInfoEnum.CmtCKey2.ToString()]);
            try
            {
                codeMasterList = dbCommand.GetRecordList(sqlString, dic);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return codeMasterList;
        }
Example #29
0
        public List<CodeMasterInfo> GetKey1s()
        {
            string sqlString = string.Empty;
            List<CodeMasterInfo> codeMasterList;
            DataBaseCommand<CodeMasterInfo> dbCommand = new DataBaseCommand<CodeMasterInfo>();

            sqlString = LocalLayer.LocalDefine.Instance.GetInitComboBoxSQL(this._dataBaseDic[CodeMasterInfoEnum.TableName.ToString()], this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()], "");
            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add(CodeMasterInfoEnum.CmtCKey1.ToString(), this._dataBaseDic[CodeMasterInfoEnum.CmtCKey1.ToString()]);
            try
            {
                codeMasterList = dbCommand.GetRecordList(sqlString, dic);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return codeMasterList;
        }
Example #30
0
        public bool IsExistRecord(string clientNum)
        {
            bool isExist = false;
            string sqlString = string.Empty;
            object valueObject = null;

            sqlString = "SELECT COUNT(1) FROM ClientMaster_clm" + Environment.NewLine;
            sqlString += " WHERE clm_cClientNum='" + clientNum.Trim().Replace("'", "''") + "'";

            DataBaseCommand<ClientMasterInfo> dataBaseCommand = new DataBaseCommand<ClientMasterInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;
            if (count > 0)
            {
                isExist = true;
            }

            return isExist;
        }
Example #31
0
        public DeptMasterInfo GetRecord(string deptNum)
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + Environment.NewLine;
            sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.DpmCDeptNumber.ToString()] + "='" + deptNum.Replace("'","''")+"'";

            DataBaseCommand<DeptMasterInfo> dbCommand = new DataBaseCommand<DeptMasterInfo>();
            DeptMasterInfo deptMasterInfo;

            try
            {
                deptMasterInfo = dbCommand.GetRecord(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return deptMasterInfo;
        }
Example #32
0
        public bool IsExistRecord(string deptNum)
        {
            bool isExist = false;
            string sqlString = string.Empty;
            object valueObject = null;

            sqlString = "SELECT COUNT(1) FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + this._newLineSybm;
            sqlString += " WHERE " + this._dataDictionary[DeptMasterInfoEnum.DpmCDeptNumber.ToString()] + "='" + deptNum.Replace("'", "''").Trim() + "'";

            DataBaseCommand<DeptMasterInfo> dataBaseCommand = new DataBaseCommand<DeptMasterInfo>();

            try
            {
                valueObject = dataBaseCommand.GetValue(sqlString, typeof(int));
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            int count = (int)valueObject;
            if (count > 0)
            {
                isExist = true;
            }

            return isExist;
        }
Example #33
0
        // обновление БД
        public void Update(byte[] Buffer)
        //public void Update(object sender, NetworkEventArgs EventArgs)
        {
            //byte[] Buffer = EventArgs.Info.Buffer;
            IsUpdating = true;
            int             ind               = 0;
            int             BufferLength      = GetInt(Buffer, ref ind);
            byte            NetworkUnitNumber = Buffer[ind++];
            DataBaseCommand Command           = (DataBaseCommand)Buffer[ind++];
            int             number;

            switch (Command)
            {
            case DataBaseCommand.None:
                break;

            case DataBaseCommand.Add:
                Add(new Book(Encoding.UTF8.GetString(Buffer, ind, BufferLength)));
                if (SaveMode == DataBaseSaving.RealTime)
                {
                    Save();
                }
                if (TransactionApproval)
                {
                    TransactCommit();
                }
                if (Logging != DataBaseLogging.None)
                {
                    AppendToLog(@"Item with name """ + this[Count - 1].Name + @""" and ISBN " +
                                this[Count - 1].ISBN + " has been added under the number " + (Count - 1).ToString());
                }
                if (Logging == DataBaseLogging.RealTime)
                {
                    SaveLog();
                }
                break;

            case DataBaseCommand.RemoveAt:
                number = GetInt(Buffer, ref ind);
                RemoveAt(number);
                if (SaveMode == DataBaseSaving.RealTime)
                {
                    Save();
                }
                if (TransactionApproval)
                {
                    TransactCommit();
                }
                if (Logging != DataBaseLogging.None)
                {
                    AppendToLog("Item under the number " + number.ToString() + " has been removed");
                }
                if (Logging == DataBaseLogging.RealTime)
                {
                    SaveLog();
                }
                break;

            case DataBaseCommand.Change:
                number       = GetInt(Buffer, ref ind);
                base[number] = new Book(Encoding.UTF8.GetString(Buffer, ind, BufferLength - ind));
                if (SaveMode == DataBaseSaving.RealTime)
                {
                    Save();
                }
                if (TransactionApproval)
                {
                    TransactCommit();
                }
                if (Logging != DataBaseLogging.None)
                {
                    AppendToLog("Item under the number " + number.ToString() + " has been changed");
                }
                if (Logging == DataBaseLogging.RealTime)
                {
                    SaveLog();
                }
                break;

            case DataBaseCommand.Clear:
                Clear();
                if (TransactionApproval)
                {
                    TransactCommit();
                }
                if (Logging != DataBaseLogging.None)
                {
                    AppendToLog("Database has been changed");
                }
                if (Logging == DataBaseLogging.RealTime)
                {
                    SaveLog();
                }
                break;

            case DataBaseCommand.Load:
                Load(Buffer, ind, BufferLength - ind);
                if (SaveMode == DataBaseSaving.RealTime)
                {
                    Save();
                }
                //if (TransactionApproval)
                //	TransactCommit();
                break;

            case DataBaseCommand.Serialize:
                Serialize();
                break;

            case DataBaseCommand.TransactCommited:
                ExecuteCommand();
                break;
            }
            IsUpdating = false;
        }
Example #34
0
        public List<Model.Master.DeptMasterInfo> GetAllRecord()
        {
            string sqlString = string.Empty;

            sqlString = "SELECT * FROM " + this._dataDictionary[DeptMasterInfoEnum.TableName.ToString()] + this._newLineSybm;

            DataBaseCommand<DeptMasterInfo> dbCommand = new DataBaseCommand<DeptMasterInfo>();
            List<DeptMasterInfo> deptMasterInfoList;

            try
            {
                deptMasterInfoList = dbCommand.GetRecordList(sqlString, this._dataDictionary);
            }
            catch (Exception Ex)
            {
                throw Ex;
            }

            return deptMasterInfoList;
        }