Exemple #1
0
        public List <HCM_Client> GetClients(int ClientID, string UserType)
        {
            List <HCM_Client> client_list = new List <HCM_Client>();
            HCM_Client        client_obj  = new HCM_Client();

            try
            {
                using (SqlConnection sql_obj = new SqlConnection())
                {
                    sql_obj.ConnectionString = sql.GetConnection();
                    sql_obj.Open();
                    using (SqlCommand cmd = new SqlCommand("HCM_PROC_GetClientsList", sql_obj))
                    {
                        cmd.CommandType    = CommandType.StoredProcedure;
                        cmd.CommandTimeout = 0;
                        // cmd.Parameters.AddWithValue("@ClientID", ClientID);
                        SqlDataAdapter da = new SqlDataAdapter(cmd);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sql_obj.Close();

                        if (dt.Rows.Count > 0)
                        {
                            if (UserType != "SuperAdmin")
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (Convert.ToInt32(dt.Rows[i]["ClientID"]) == ClientID)
                                    {
                                        client_obj            = new HCM_Client();
                                        client_obj.ClientID   = Convert.ToInt32(dt.Rows[i]["ClientID"]);
                                        client_obj.ClientName = Convert.ToString(dt.Rows[i]["ClientName"]);
                                        client_list.Add(client_obj);
                                    }
                                }
                            }
                            else
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    client_obj            = new HCM_Client();
                                    client_obj.ClientID   = Convert.ToInt32(dt.Rows[i]["ClientID"]);
                                    client_obj.ClientName = Convert.ToString(dt.Rows[i]["ClientName"]);
                                    client_list.Add(client_obj);
                                }
                            }
                        }
                    }
                }
                return(client_list);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        public List <HCM_Client> GetAllClients()
        {
            List <HCM_Client> hcm_ClientList_Obj = new List <HCM_Client>();
            HCM_Client        hcm_Clients_Obj    = new HCM_Client();

            try
            {
                using (SqlConnection sqlcon_Obj = new SqlConnection())
                {
                    sqlcon_Obj.ConnectionString = con.GetConnection();
                    sqlcon_Obj.Open();
                    using (SqlCommand sqlcmd_Obj = new SqlCommand("HCM_PROC_GetClientsList", sqlcon_Obj))
                    {
                        sqlcmd_Obj.CommandTimeout = 0;
                        sqlcmd_Obj.CommandType    = CommandType.StoredProcedure;
                        SqlDataAdapter da = new SqlDataAdapter(sqlcmd_Obj);
                        DataTable      dt = new DataTable();
                        da.Fill(dt);
                        sqlcon_Obj.Close();

                        if (dt.Rows.Count > 0)
                        {
                            for (var i = 0; i < dt.Rows.Count; i++)
                            {
                                hcm_Clients_Obj             = new HCM_Client();
                                hcm_Clients_Obj.ClientID    = Convert.ToInt32(dt.Rows[i]["ClientID"]);
                                hcm_Clients_Obj.ClientName  = Convert.ToString(dt.Rows[i]["ClientName"]);
                                hcm_Clients_Obj.ClientEmail = Convert.ToString(dt.Rows[i]["ClientEmail"]);
                                hcm_Clients_Obj.CreatedOn   = Convert.ToDateTime(dt.Rows[i]["CreatedOn"]);
                                hcm_Clients_Obj.Status      = Convert.ToBoolean(dt.Rows[i]["Status"]);
                                hcm_ClientList_Obj.Add(hcm_Clients_Obj);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(hcm_ClientList_Obj);
        }