예제 #1
0
        /// <summary>
        /// Description: Delete method
        /// </summary>
        /// <param name="oEntity"></param>
        /// <param name="ht"></param>
        /// <returns>Boolean</returns>
        public bool Delete(MasterEntity oEntity, Hashtable ht)
        {
            bool flag = false;

            try
            {
                DataSet DTSet = FillEntityWithValues(oEntity);
                flag = this.oDalc.CRUD(DTSet, ht);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }
예제 #2
0
        /// <summary>
        /// Description: Get data which need to be fetch on Auto Complete Dropdown's
        /// </summary>
        /// <param name="oEntity"></param>
        /// <param name="ht"></param>
        /// <returns>List<object></returns>
        public List <object> GetAutoData(MasterEntity oEntity, Hashtable ht)
        {
            List <object> ol = new List <object>();

            try
            {
                DataSet DTSet = FillEntityWithValues(oEntity);
                DataSet ds    = this.oDalc.GetAutoDataSet(DTSet, ht);
                if (ds != null && ds.Tables.Count >= 1)
                {
                    ol.Add(MyCommonFunctions.DataSetToJSON(ds));
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(ol);
        }
예제 #3
0
        /// <summary>
        /// This method is used to get Initial data in dataset
        /// </summary>
        /// <param name="DataSet"></param>
        /// <param name="Hashtable"></param>
        /// <returns></returns>
        public DataSet GetInitDataSet(DataSet DTSet, Hashtable ht)
        {
            DataSet ds = new DataSet();

            try
            {
                //if DTSet is null then pass blank DBStructure to SP
                if (DTSet == null)
                {
                    DTSet = new MasterEntity().GetTablesStructure();
                }

                using (SqlConnection con = base.GetConnection())
                {
                    using (SqlCommand cmd = new SqlCommand(MasterEntity.StoredProcedures.CRUD, con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        SqlParameter parameter = new SqlParameter(MasterEntity.Parameters.Param_TypeTable_LoggedInUserDetails, DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails]);
                        parameter.SqlDbType = SqlDbType.Structured;
                        parameter.TypeName  = MasterEntity.DBTableAndType.TYPE_TABLE_LoggedInUserDetails;
                        cmd.Parameters.Add(parameter);

                        // SQL TypeTable Parameter for Auto Search or Global Search (Common Search) Table
                        parameter           = new SqlParameter(MasterEntity.Parameters.Param_TypeTable_LoggedInUserDetails_CommonSearch, DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails_CommonSearch]);
                        parameter.SqlDbType = SqlDbType.Structured;
                        parameter.TypeName  = MasterEntity.DBTableAndType.TYPE_TABLE_LoggedInUserDetails_CommonSearch;
                        cmd.Parameters.Add(parameter);

                        if (ht != null)
                        {
                            // Operation mode
                            if (ht[MyCommonEntity.Fields.OPERATIONMODE] != null)
                            {
                                cmd.Parameters.Add(MyCommonEntity.Parameters.OperationMode, SqlDbType.VarChar, 10).Value = ht[MyCommonEntity.Fields.OPERATIONMODE];
                            }

                            #region Output parameter
                            // this represent Output parameter
                            if (ht[MasterEntityFields.LOGGEDINUSERID] != null)
                            {
                                cmd.Parameters.Add(MasterEntity.Parameters.Param_LoggedInUserID, SqlDbType.Int).Value = ht[MasterEntityFields.LOGGEDINUSERID];
                            }
                            else
                            {
                                cmd.Parameters.Add(MasterEntity.Parameters.Param_LoggedInUserID, SqlDbType.Int).Value = 0;
                            }

                            cmd.Parameters[MasterEntity.Parameters.Param_LoggedInUserID].Direction = ParameterDirection.InputOutput;
                            #endregion
                        }

                        SqlDataAdapter AdapterObj = new SqlDataAdapter(cmd);
                        AdapterObj.TableMappings.Add("Table", MasterEntity.DataTableName.DTData);
                        AdapterObj.Fill(ds);
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw sqlException;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(ds);
        }
예제 #4
0
        /// <summary>
        /// Description: Perform Add/Update/deleted operation
        /// </summary>
        /// <param name="DataSet"></param>
        /// <param name="Hashtable"></param>
        /// <returns></returns>
        public bool CRUD(DataSet DTSet, Hashtable ht)
        {
            bool flag = false;

            try
            {
                //if DTSet is null then pass blank DBStructure to SP
                if (DTSet == null)
                {
                    DTSet = new MasterEntity().GetTablesStructure();
                }

                using (SqlConnection con = base.GetConnection())
                {
                    using (SqlCommand cmd = new SqlCommand(MasterEntity.StoredProcedures.CRUD, con))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        SqlParameter parameter = new SqlParameter(MasterEntity.Parameters.Param_TypeTable_LoggedInUserDetails, DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails]);
                        parameter.SqlDbType = SqlDbType.Structured;
                        parameter.TypeName  = MasterEntity.DBTableAndType.TYPE_TABLE_LoggedInUserDetails;
                        cmd.Parameters.Add(parameter);

                        // SQL TypeTable Parameter for Auto Search or Global Search (Common Search) Table
                        parameter           = new SqlParameter(MasterEntity.Parameters.Param_TypeTable_LoggedInUserDetails_CommonSearch, DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails_CommonSearch]);
                        parameter.SqlDbType = SqlDbType.Structured;
                        parameter.TypeName  = MasterEntity.DBTableAndType.TYPE_TABLE_LoggedInUserDetails_CommonSearch;
                        cmd.Parameters.Add(parameter);

                        if (ht != null)
                        {
                            // Operation mode
                            if (ht[MyCommonEntity.Fields.OPERATIONMODE] != null)
                            {
                                cmd.Parameters.Add(MyCommonEntity.Parameters.OperationMode, SqlDbType.VarChar, 10).Value = ht[MyCommonEntity.Fields.OPERATIONMODE];
                            }

                            #region Output parameter
                            // this represent Output parameter
                            if (ht[MasterEntityFields.LOGGEDINUSERID] != null)
                            {
                                cmd.Parameters.Add(MasterEntity.Parameters.Param_LoggedInUserID, SqlDbType.Int).Value = ht[MasterEntityFields.LOGGEDINUSERID];
                            }
                            else
                            {
                                cmd.Parameters.Add(MasterEntity.Parameters.Param_LoggedInUserID, SqlDbType.Int).Value = 0;
                            }

                            cmd.Parameters[MasterEntity.Parameters.Param_LoggedInUserID].Direction = ParameterDirection.InputOutput;
                            #endregion
                        }

                        cmd.Connection.Open();
                        flag = cmd.ExecuteNonQuery() > 0;

                        if (flag)
                        {
                            ht[MasterEntityFields.LOGGEDINUSERID] = Convert.ToInt32(cmd.Parameters[MasterEntity.Parameters.Param_LoggedInUserID].Value);
                        }
                    }
                }
            }
            catch (SqlException sqlException)
            {
                throw sqlException;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(flag);
        }
예제 #5
0
        /// <summary>
        /// Description: Fill DataSet with Actual Values which needs to be send on DB
        /// </summary>
        /// <param name="oEntity"></param>
        /// <returns>Convert oEntity to DataSet which contains data in DataTable collection format</returns>
        public DataSet FillEntityWithValues(MasterEntity oEntity)
        {
            DataSet   DTSet         = new MasterEntity().GetTablesStructure();
            DataTable DTMasterTable = DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails];
            DataTable DT_LOGGEDINUSERDETAILS_COMMONSEARCH = DTSet.Tables[MasterEntity.DBTableAndType.TABLE_LoggedInUserDetails_CommonSearch];

            DataRow dr = DTMasterTable.NewRow();

            try
            {
                if (oEntity.LoggedInUserID != null)
                {
                    dr[MasterEntityFields.LOGGEDINUSERID] = oEntity.LoggedInUserID;
                }

                if (oEntity.UserName != null)
                {
                    dr[MasterEntityFields.USERNAME] = oEntity.UserName;
                }

                if (oEntity.IsLoggedInNow != null)
                {
                    dr[MasterEntityFields.ISLOGGEDINNOW] = oEntity.IsLoggedInNow;
                }

                if (oEntity.LoggedInFromDomain != null)
                {
                    dr[MasterEntityFields.LOGGEDINFROMDOMAIN] = oEntity.LoggedInFromDomain;
                }

                if (oEntity.LoggedInAt != null)
                {
                    dr[MasterEntityFields.LOGGEDINAT] = oEntity.LoggedInAt;
                }

                if (oEntity.LoggedInFromIP != null)
                {
                    dr[MasterEntityFields.LOGGEDINFROMIP] = oEntity.LoggedInFromIP;
                }

                if (oEntity.LoggedInUserAgent != null)
                {
                    dr[MasterEntityFields.LOGGEDINUSERAGENT] = oEntity.LoggedInUserAgent;
                }

                DTMasterTable.Rows.Add(dr);
                DTMasterTable.AcceptChanges();

                // Collect the information from oEntity LoggedInUserDetails_CommonSearch and fill the data in DT_LOGGEDINUSERDETAILS_COMMONSEARCH DataTable
                if (oEntity.LoggedInUserDetails_CommonSearchList != null)
                {
                    foreach (ChildLoggedInUserDetails_CommonSearchEntity oEntity_ in oEntity.LoggedInUserDetails_CommonSearchList)
                    {
                        //Initialize New row with DataTable
                        dr = DT_LOGGEDINUSERDETAILS_COMMONSEARCH.NewRow();

                        if (oEntity_.UserName != null)
                        {
                            dr[ChildLoggedInUserDetails_CommonSearchEntityFields.USERNAME] = oEntity_.UserName;
                        }

                        if (oEntity_.LoggedInFromDomain != null)
                        {
                            dr[ChildLoggedInUserDetails_CommonSearchEntityFields.LOGGEDINFROMDOMAIN] = oEntity_.LoggedInFromDomain;
                        }

                        //Add Row into DataTable
                        DT_LOGGEDINUSERDETAILS_COMMONSEARCH.Rows.Add(dr);
                    }

                    // Save State of DataTable with Currently filled Data
                    DT_LOGGEDINUSERDETAILS_COMMONSEARCH.AcceptChanges();
                }
            }
            catch (Exception exe)
            {
                throw exe;
            }
            return(DTSet);
        }