Posts

Showing posts from 2015

how to Replace null value with 0 Using C#

how to Replace null value with 0 Using C# //here we suppose that objDataTable have data collection as table now access this //datatable object. decimal  j = 0;  j = objDataTable.Rows[0]["Qty"] ==  DBNull .Value ? 0 :  Convert .ToDecimal(objDataTable.Rows[0]["Qty"]); NOTE :- //if   DBNull.value is null  then   "0 " else  "your code here")  // ? = then // : = else Thank You [Sumit Singh Shekhawat]

Calculate simple interst using c sharp in console application

Image
How to calculate SI (Simple Interest) using C# in Console Application _____________________ start _________________________ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Oops_Concepts {     class Program     {         static void Main()         {             Program objProgram = new Program();             objProgram.GetSimpleInterest();             Console.Read();               }          public void GetSimpleInterest()         {             double principle, interst = 0;             int time = 0;                          Console.Write("Enter Principle Am...

Calculate Mortgage in c# using console application

Formula :  M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1] M = monthly mortgage payment P = the principal, or the initial amount you borrowed. i = your monthly interest rate. Your lender likely lists interest rates as an annual figure, so you’ll need to divide by 12, for each month of the year. So, if your rate is 5%, then the monthly rate will look like this: 0.05/12 = 0.004167. n = the number of payments, or the payment period in months. If you take out a 30-year fixed rate mortgage, this means: n = 30 years x 12 months per year, or 360 payments. ___________________________________  Start Code  _________________________________ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Oops_Concepts {     class Program     {         static void Main(string[] args)         {             Program objProgram = new Program();   ...

Cookies in ASP.NET

Cookies is a small piece of information stored on the client machine. This file is located on client machines "C:\Document and Settings\Currently_Login user\Cookie" path.  Its is used to store user preference information like Username, Password,City and PhoneNo etc on client machines. We need to import namespace called  Systen.Web.HttpCookie before we use cookie. Type of Cookies? Persist Cookie - A cookie has not have expired time Which is called as Persist Cookie Non-Persist Cookie - A cookie has expired time Which is called as Non-Persist Cookie How to create a cookie?  Its really easy to create a cookie in the Asp.Net with help of Response object or HttpCookie Example 1 :             HttpCookie  userInfo =  new   HttpCookie ( "userInfo" );         userInfo[ "UserName" ] =  "Annathurai" ;         userInfo[ "UserColor"...

Alert Message using C#

Alert Message Using C# in ASP.NET  --------------------- Method 1 ScriptManager .RegisterClientScriptBlock( this , this .GetType(), "alertMessage" , "alert('Your Selected AccountID is : " + AccountID + "')" , true ); -------------------- Method 2 ClientScript.RegisterStartupScript ( this .GetType(), "alert" , "alert('Insert is successfull')" , true ); 

Calculate Simple Interest

Calculate Simple Intersert  Calculate Simple Interest in Sql Server 2008 DECLARE @P float ; DECLARE @R float ; DECLARE @T float ; DECLARE @SI float ;     set @P = 50000 ;     set @R = 05;     set @T = 05;     set @SI = @P*@R*@T/100     select @SI as 'Simple Interest'   Calculate Compound Interest select @P* POWER ((1+@R/100),@T)-@P as 'compoundInterest'  
Image
WRITE ON GOOGLE CHROME LIKE NOTEPAD PASTE THIS URL IN CHROME BROWSER : AND WRITE LIKE NOTE PADE ;)
Remove HTML Tages from Datatable In C# First Create This Function.  Public string RemoveHTMLTags( string source)  {         return Regex .Replace(source, "<.*?>", string .Empty);  } And Then use like this ---------------------------- // Data Stored in DataTable if (dt.Rows.Count > 0) { string strterm = Convert .ToString(dt.Rows[0]["term"].ToString()); strterm = RemoveHTMLTags(strterm); } else { }

Page authentication on web pages

Page authentication in web pages Web.config : < system.web >      < compilation debug = " true " targetFramework = " 4.0 " />              < authentication mode = " Forms " >      < forms loginUrl = " Default.aspx " name = " login " timeout = " 120 " ></ forms >      </ authentication >          < authorization >           < deny users = " ? " />      </ authorization >         </ system.web > Login.aspx : protected void btnLogin_Click( object sender, EventArgs e)     {         SqlConnection con = new SqlConnection ( ConfigurationManager .ConnectionStrings[ "dbconnection" ...

Tree view in winforms using c#

Image
Tree view in c# ms sqlserver 2008(database) __________________________ step 1 _________ CREATE TABLE [dbo].[myTable]( [ID] [int] IDENTITY(1,1) NOT NULL, [title] [varchar](255) NOT NULL, [parentID] [int] NULL,  CONSTRAINT [PK_myTable] PRIMARY KEY CLUSTERED  ( [ID] ASC )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY] ) ON [PRIMARY] step 2 _________ INSERT INTO myTable(title, parentID) VALUES('Microsoft', NULL) INSERT INTO myTable( title, parentID) VALUES('C#', 1) INSERT INTO myTable( title, parentID) VALUES('VB.net', 1) INSERT INTO myTable( title, parentID) VALUES('Open Source', NULL) INSERT INTO myTable( title, parentID) VALUES('Python', 4) INSERT INTO myTable( title, parentID) VALUES('Ruby', 4) INSERT INTO myTable( title, parentID) VALUES('PHP', 4) INSERT INTO myTable( title, parentID) VALUES('Perl...

How to bind xml data with combobox using c#

Image
how to bind xml data with combobox using c# =================== START ===================  XMLFile1.xml =================== ====================================== Form1.cs =================== private void Form1_Load(object sender, EventArgs e)         {             DataBind();         } private void DataBind()         {             XmlTextReader Objxml = new XmlTextReader("C:\\Users\\nitin\\Documents\\Visual Studio 2010\\Projects\\WindowsFormsApplication1\\WindowsFormsApplication1\\XMLFile1.xml");             DataSet objdataset = new DataSet();             objdataset.ReadXml(Objxml);             comboBox1.DataSource = objdataset.Tables[0];             comboBox1.DisplayMember = "Name";         ...

Retrieve (Get) data from Database using Web Mehthod in asp.net

Image
Retrieve (Get) data from Database using Web Mehthod in asp.net   pagename.aspx   pagename.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Data; using System.Data.SqlClient; using System.Web.Services; public partial class Multiplefileuploader : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             Getselect_tbl();         }     }     protected void UploadMultipleFiles(object sender, EventArgs e)     {     }     [WebMethod]     public static List Getselect_tbl()     { ...