using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.SqlClient; using System.Configuration; using System.Data; using nmsSetup; /// /// Summary description for Function /// public class Function { SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString); public List binddropdown(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if(pro.id!="-1") cmd.Parameters.AddWithValue("@id",pro.id); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = null; while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } public List binddropdownI(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if (pro.id != "-1") cmd.Parameters.AddWithValue("@id", pro.id); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = new PRPSetup(); prp.id = "0"; prp.name = "Select"; lst.Add(prp); while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } public List binddropdownII(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if (pro.id != "-1") cmd.Parameters.AddWithValue("@id", pro.id); cmd.Parameters.AddWithValue("@isActive", pro.isActive); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = new PRPSetup(); prp.id = "0"; prp.name = "Select"; lst.Add(prp); while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } public List binddropdown2Parm(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if (pro.id != "-1") cmd.Parameters.AddWithValue("@id", pro.id); if (pro.uniID != "-1") cmd.Parameters.AddWithValue("@uniId", pro.uniID); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = null; while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } public List binddropdown2ParmI(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if (pro.id != "-1") cmd.Parameters.AddWithValue("@id", pro.id); if (pro.uniID != "-1") cmd.Parameters.AddWithValue("@uniId", pro.uniID); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = new PRPSetup(); prp.id = "0"; prp.name = "Select"; lst.Add(prp); while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } //--------------------Bind DropDown End----------------------------------- //-------------Bind Authority-------------------------------// public List binddropdownAuthority(PRPSetup pro) { List lst = new List(); SqlCommand cmd = new SqlCommand(); try { if (con.State != System.Data.ConnectionState.Open) con.Open(); cmd.Connection = con; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandText = pro.name; if (pro.id != "-1") cmd.Parameters.AddWithValue("@id", pro.id); cmd.Parameters.AddWithValue("@cId", pro.codeId); SqlDataReader Reader = cmd.ExecuteReader(); PRPSetup prp = null; while (Reader.Read()) { prp = new PRPSetup(); prp.id = Reader["id"].ToString(); prp.name = Reader["name"].ToString(); prp.status = Reader["Status"].ToString(); prp.title = Reader["Title"].ToString(); lst.Add(prp); } } catch (Exception ex) { throw ex; } finally { if (con.State != System.Data.ConnectionState.Closed) con.Close(); } return lst; } //------------End Bind Authority-------------------------------// public String IntoWord(Int32 value) { String[] son = {"One","Two","Three","Four","Five","six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen","Twenty","Twenty One" ,"Twenty Two","Twenty Three","Twenty Four","Twenty Five","Twenty Six","Twenty Seven","Twenty Eight","Twenty Nine","Thirty","Thirty One","Thirty Two","Thirty Three","Thirty Four","Thirty Five","Thirty Six" ,"Thirty Seven","Thirty Eight","Thirty Nine","Fourty","Fourty One","Fourty Two","Fourty Three","Fourty Four","Fourty Five","Fourty Six","Fourty Seven","Fourty Eight","Fourty Nine" ,"Fifty","Fifty One","Fifty Two","Fifty Three","Fifty Four","Fifty Five","Fifty Six","Fifty Seven","Fifty Eight","Fifty Nine","Sixty","Sixty One","Sixty Two","Sixty Three","Sixty Four","Sixty Five" ,"Sixty Six","Sixty Seven","Sixty Eight","Sixty Nine","Seventy","Seventy One","Seventy Two","Seventy Three","Seventy Four","Seventy Five","Seventy Six","Seventy Seven","Seventy Eight","Seventy Nine","Eighty" ,"Eighty One","Eighty Two","Eighty Three","Eighty Four","Eighty Five","Eighty Six","Eighty Seven","Eighty Eight","Eighty Nine","Ninety","Ninety One","Ninety Two","Ninety Three","Ninety Four","Ninety Five" ,"Ninety Six","Ninety Seven","Ninety Eight","Ninety Nine" }; Int32 ss = 0, i, j, no, s = 0; String[] kul = new String[50]; String save = ""; no = Convert.ToInt32(value); if (no == 0) save = save + "Zero" + " "; while (no > 0) { if (s == 1) { j = no % 10; no = no / 10; } else { j = no % 100; no = no / 100; } for (i = 0; j > 0 && i < 100; i++) { if ((i + 1) == j) { kul[ss] = son[i]; ss++; break; } } s++; if (no > 0) { if ((no % 10) != 0) { if (s == 1) { kul[ss] = "Hundred"; ss++; } } if ((no % 100) != 0) { if (s == 2) { kul[ss] = "Thousand"; ss++; } else if (s == 3) { kul[ss] = "laks"; ss++; } else if (s == 4) { kul[ss] = "crore"; ss++; } //Here u can give more condition according to u r need for example million, billion etc. } } } for (i = ss - 1; i >= 0; i--) save = save + kul[i] + " "; save = save + "only"; return save; } }