Skip to main content

Posts

Highest salary query in sql server

DECLARE @dtDepartment TABLE ( Id int, Name varchar(100) ) DECLARE @dtEmployee TABLE ( Id int, Name varchar(100), DeptId int ) DECLARE @dtEmpSalary TABLE ( Id int, EmpId int, Salary int ) INSERT INTO @dtDepartment VALUES(1,'.NET') INSERT INTO @dtDepartment VALUES(2,'Java') INSERT INTO @dtEmployee VALUES(1,'Brijesh',1) INSERT INTO @dtEmployee VALUES(2,'Parth',1) INSERT INTO @dtEmployee VALUES(3,'Ruchir 1',1) INSERT INTO @dtEmployee VALUES(4,'Jainik 1',1) INSERT INTO @dtEmployee VALUES(5,'Ruchir',2) INSERT INTO @dtEmployee VALUES(6,'Jainik',2) INSERT INTO @dtEmployee VALUES(7,'Jainik',2) INSERT INTO @dtEmployee VALUES(8,'Jainik',2) INSERT INTO @dtEmpSalary VALUES(1,1,10000) INSERT INTO @dtEmpSalary VALUES(2,2,15000) INSERT INTO @dtEmpSalary VALUES(3,3,12000) INSERT INTO @dtEmpSalary VALUES(4,4,12000) INSERT INTO @dtEmpSalary VALUES(5,5,12000) INSERT INTO @dtEmpSa
Recent posts

CRUD in EF

 public int Create(Users entity)         {             using (var context = new K305DataEntities())             {                 var newEntity = Mapper.Map<User>(entity);                             context.Users.Add(newEntity);                 context.SaveChanges();                 return newEntity.Id;             }         }         public int Update(Users entity)         {             using (var context = new K305DataEntities())             {                 var dbEntity = context.Users.FirstOrDefault(dc => dc.Id == entity.Id);                 if (dbEntity == null) throw new ApplicationException("Entity not found.");                 dbEntity.Name = entity.Name;                 context.SaveChanges();                 return dbEntity.Id;             }                 }         public List<Users> GetAll()         {             using (var context = new K305DataEntities())             {                 return context.Users.Select(

QueryString Encode & Decode

QueryString Encode & Decode Helper Class public class clsQueryString { static public string QueryStringEncode( string value) { return clsEncryptionDecryption .GetEncrypt(value); } static public string QueryStringDecode( string value) { return clsEncryptionDecryption .GetDecrypt(value); } public static string GetValueFromQueryString( string value, string key) { string strValue = string .Empty; if (value != null ) { string DataString = clsEncryptionDecryption .GetDecrypt(value); Hashtable objHash = clsQueryString .GetQueryString(DataString); strValue = clsCheckDBNull .ConvertToStr(objHash[key]); return strValue; } else return "" ; } publi

Encryption Decryption Helper

Encryption Decryption Helper public class clsEncryptionDecryption { #region Variable Declaration private static string keyString = " keyString "; #endregion #region Methods/Functions /// <summary> /// Get Encrpted Value of Passed value /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks></remarks> public static string GetEncrypt( string value) { return Encrypt(keyString, value); } /// <summary> /// Get Decrypted value of passed encrypted string /// </summary> /// <param name="value"></param> /// <returns></returns> /// <remarks></remarks> public static string

Message Helper for MVC Application

Message Helper for MVC Application public static class MessageExtensions { public enum MessageType { Success = 0, Info = 1, Warning = 2, Error = 3 } public static void ShowMessage( this Controller controller, MessageType messageType, string message, bool showAfterRedirect = false ) { string messageTypeKey = messageType.ToString(); if (showAfterRedirect) { controller.TempData[messageTypeKey] = message; } else { controller.ViewData[messageTypeKey] = message; } } public static HtmlString RenderMessages( this HtmlHelper htmlHelper, bool clearMessage = true ) { string messages = String .Empty; foreach ( string messageType in Enum .GetNames( t