| Server IP : 199.79.62.161 / Your IP : 216.73.216.245 [ Web Server : Microsoft-IIS/10.0 System : Windows NT MDUS-PP-WB12 10.0 build 20348 (Windows Server 2022) AMD64 User : IWPD_5096(nirmaowd) ( 0) PHP Version : 8.3.30 Disable Function : NONE Domains : 0 Domains MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : D:/INETPUB/VHOSTS/nirmalamatha.edu.in/ponnuguruvayurappan.org/App_Code/ |
Upload File : |
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Security.Cryptography;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Net;
using System.Net.Mail;
public class Common
{
public static string Convert2String(object value)
{
if (value == DBNull.Value)
return string.Empty;
return Convert.ToString(value);
}
public static bool IsValidDate(string _date)
{
string[] dates = _date.Split('/');
int _flag = 0;
if (dates.Length == 3)
{
try
{
DateTime CheckDate = new DateTime(int.Parse(dates[2]), int.Parse(dates[1]), int.Parse(dates[0]));
}
catch
{
_flag = 1;
}
}
else
{
_flag = 1;
}
if (_flag == 0) return true;
else return false;
}
public static string Encrypt(string strText, string strEncrypt)
{
byte[] byKey = new byte[20];
byte[] dv ={ 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
try
{
byKey = System.Text.Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
byte[] inputArray = System.Text.Encoding.UTF8.GetBytes(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(byKey, dv), CryptoStreamMode.Write);
cs.Write(inputArray, 0, inputArray.Length);
cs.FlushFinalBlock();
return Convert.ToBase64String(ms.ToArray());
}
catch (Exception ex)
{
string str = ex.Message;
throw ex;
}
}
public static string Decrypt(string strText, string strEncrypt)
{
byte[] bKey = new byte[20];
byte[] IV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
try
{
bKey = System.Text.Encoding.UTF8.GetBytes(strEncrypt.Substring(0, 8));
DESCryptoServiceProvider des = new DESCryptoServiceProvider();
Byte[] inputByteArray = inputByteArray = Convert.FromBase64String(strText);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(bKey, IV), CryptoStreamMode.Write);
cs.Write(inputByteArray, 0, inputByteArray.Length);
cs.FlushFinalBlock();
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
return encoding.GetString(ms.ToArray());
}
catch (Exception ex)
{
throw ex;
}
}
public static bool IsNull(object value)
{
if (value == DBNull.Value)
return true;
else if (value == null)
return true;
else
return false;
}
public static void CreateThumbnails(string lcFilename, int lnWidth, int lnHeight)
{
System.Drawing.Bitmap bmpOut = null;
try
{
Bitmap loBMP = new Bitmap(lcFilename);
ImageFormat loFormat = loBMP.RawFormat;
decimal lnRatio;
int lnNewWidth = 0;
int lnNewHeight = 0;
if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
{
loBMP.Dispose();
return;
}
if (loBMP.Width > loBMP.Height)
{
lnRatio = (decimal)lnWidth / loBMP.Width;
lnNewWidth = lnWidth;
decimal lnTemp = loBMP.Height * lnRatio;
lnNewHeight = (int)lnTemp;
}
else
{
lnRatio = (decimal)lnHeight / loBMP.Height;
lnNewHeight = lnHeight;
decimal lnTemp = loBMP.Width * lnRatio;
lnNewWidth = (int)lnTemp;
}
bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
loBMP.Dispose();
bmpOut.Save(lcFilename);
bmpOut.Dispose();
}
catch { }
}
public static void CreateThumbnail(string inFilename, string outFilename, int lnWidth, int lnHeight)
{
System.Drawing.Bitmap bmpOut = null;
try
{
Bitmap loBMP = new Bitmap(inFilename);
ImageFormat loFormat = loBMP.RawFormat;
decimal lnRatio;
int lnNewWidth = 0;
int lnNewHeight = 0;
if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
{
loBMP.Save(outFilename);
loBMP.Dispose();
return;
}
if (loBMP.Width > loBMP.Height)
{
lnRatio = (decimal)lnWidth / loBMP.Width;
lnNewWidth = lnWidth;
decimal lnTemp = loBMP.Height * lnRatio;
lnNewHeight = (int)lnTemp;
}
else
{
lnRatio = (decimal)lnHeight / loBMP.Height;
lnNewHeight = lnHeight;
decimal lnTemp = loBMP.Width * lnRatio;
lnNewWidth = (int)lnTemp;
}
bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
loBMP.Dispose();
bmpOut.Save(outFilename);
bmpOut.Dispose();
}
catch { }
}
public static void SendMail(string fromaddr, string toaddr, string subject, string body, bool HasHtmlBody)
{
MailMessage message = new MailMessage(fromaddr, toaddr);
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailHost"]);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["SiteMailAddr"], ConfigurationManager.AppSettings["SiteMailPwd"]);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = HasHtmlBody;
smtp.Send(message);
}
public static void SendMail(string toaddr, string subject, string body, bool HasHtmlBody)
{
MailMessage message = new MailMessage(ConfigurationManager.AppSettings["SiteMailAddr"], toaddr);
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailHost"]);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["SiteMailAddr"], ConfigurationManager.AppSettings["SiteMailPwd"]);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = HasHtmlBody;
smtp.Send(message);
}
public static void SendMailWithBcc(string toaddr,string[] bcc,string subject, string body, bool HasHtmlBody)
{
MailMessage message = new MailMessage(ConfigurationManager.AppSettings["SiteMailAddr"], toaddr);
for (int i = 0; i < bcc.Length; i++)
{
message.Bcc.Add(bcc[i]);
}
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailHost"]);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["SiteMailAddr"], ConfigurationManager.AppSettings["SiteMailPwd"]);
message.Subject = subject;
message.Body = body;
message.IsBodyHtml = HasHtmlBody;
smtp.Send(message);
}
public static string ValidSQL(string content)
{
return content.Replace("'", "''");
}
public void SendMail(string toaddr, string subject, string body, string AttachPath)
{
using (MailMessage message = new MailMessage(ConfigurationManager.AppSettings["SiteMailAddr"], toaddr))
{
SmtpClient smtp = new SmtpClient(ConfigurationManager.AppSettings["MailHost"]);
smtp.UseDefaultCredentials = false;
smtp.Credentials = new NetworkCredential(ConfigurationManager.AppSettings["SiteMailAddr"], ConfigurationManager.AppSettings["SiteMailPwd"]);
message.Subject = subject;
message.Body = body;
message.Attachments.Add(new Attachment(AttachPath));
message.IsBodyHtml = true;
smtp.Send(message);
}
}
}
public class DataGridTemplate : ITemplate
{
ListItemType templateType;
string columnName;
string Id;
public DataGridTemplate(ListItemType type, string colname,string id)
{
templateType = type;
columnName = colname;
Id = id;
}
public void InstantiateIn(System.Web.UI.Control container)
{
Literal lc = new Literal();
switch (templateType)
{
case ListItemType.Header:
lc.Text = "<B>" + columnName + "</B>";
container.Controls.Add(lc);
break;
case ListItemType.Item:
TextBox txt = new TextBox();
txt.ID = Id;
container.Controls.Add(txt);
break;
}
}
}