Translate

Home > January 2013

January 2013

C# Time To Word (Bangla)

Sunday, January 27, 2013 Category : 0

class TimeToWord
    {
        public string ConvertEnglish()
        {
            return "";
        }

        public string ConvertBangla(DateTime dt)
        {
            int hour = dt.Hour;
            int minute = dt.Minute;

            string BanglaValue = "";

            if (hour < 12)
            {
                BanglaValue += @"সকাল";
            }
            else if (hour >= 12)
            {
                BanglaValue += @"দুপুর";
            }

            #region hour in bangla
            if (hour == 1) { BanglaValue += @" একটা"; }
            else if (hour == 2) { BanglaValue += @" দুইটা"; }
            else if (hour == 3) { BanglaValue += @" তিনটা"; }
            else if (hour == 4) { BanglaValue += @" চারটা"; }
            else if (hour == 5) { BanglaValue += @" পাচঁটা"; }
            else if (hour == 6) { BanglaValue += @" ছয়টা"; }
            else if (hour == 7) { BanglaValue += @" সাতটা"; }
            else if (hour == 8) { BanglaValue += @" আটটা"; }
            else if (hour == 9) { BanglaValue += @" নয়টা"; }
            else if (hour == 10) { BanglaValue += @" দশটা"; }
            else if (hour == 11) { BanglaValue += @" এগারোটা"; }
            else if (hour == 12) { BanglaValue += @" বারোটা"; }
            else if (hour == 13) { BanglaValue += @" একটা"; }
            else if (hour == 14) { BanglaValue += @" দুইটা"; }
            else if (hour == 15) { BanglaValue += @" তিনটা"; }
            else if (hour == 16) { BanglaValue += @" চারটা"; }
            else if (hour == 17) { BanglaValue += @" পাচঁটা"; }
            else if (hour == 18) { BanglaValue += @" ছয়টা"; }
            else if (hour == 19) { BanglaValue += @" সাতটা"; }
            else if (hour == 20) { BanglaValue += @" আটটা"; }
            else if (hour == 21) { BanglaValue += @" নয়টা"; }
            else if (hour == 22) { BanglaValue += @" দশটা"; }
            else if (hour == 23) { BanglaValue += @" এগারোটা"; }
            else if (hour == 24) { BanglaValue += @" বারোটা"; }
            #endregion


            #region minute in bangla
            if (minute == 1) { BanglaValue += @" এক"; }
            else if (minute == 2) { BanglaValue += @" দুই"; }
            else if (minute == 3) { BanglaValue += @" তিন"; }
            else if (minute == 4) { BanglaValue += @" চার"; }
            else if (minute == 5) { BanglaValue += @" পাচঁ"; }
            else if (minute == 6) { BanglaValue += @" ছয়"; }
            else if (minute == 7) { BanglaValue += @" সাত"; }
            else if (minute == 8) { BanglaValue += @" আট"; }
            else if (minute == 9) { BanglaValue += @" নয়"; }
            else if (minute == 10) { BanglaValue += @" দশ"; }
            else if (minute == 11) { BanglaValue += @" এগারো"; }
            else if (minute == 12) { BanglaValue += @" বারো"; }

                /*
                 * তেরো চৈাদ্দো্ পনেরো ষোলো সতেরো আঠারো উনিশ বিষ একুশ বাইষ তেইশ চব্বিশ পঁচিশ ছ্ছাব্বিশ সাতাইশ আঠাইশ
উনত্রিশ ত্রিশ একত্রিশ বত্রিশ তেত্রিশ চৈাত্রিশ পয়ত্রিশ ছত্রিশ সাইত্রিশ আটত্রিশ উনচল্লিশ চল্লিশ একল্লিশ বিয়াল্লিশ তেতাল্লিশ চুয়াল্লিশ পঁয়তাল্লিশ ছেঁচোল্লিশ সাতচল্লিশ
                 * আটচল্লিশ উনপন্চাশ পঞ্চাশ একান্নো বাহান্নো তিপ্পান্নো চুয়ান্নো পঞ্চান্নো ছাপ্পানো সাতান্নো আটান্নো উনষাট
                 * */

            else if (minute == 13) { BanglaValue += @" তেরো"; }
            else if (minute == 14) { BanglaValue += @" চৈাদ্দো্"; }
            else if (minute == 15) { BanglaValue += @" পনেরো"; }
            else if (minute == 16) { BanglaValue += @" ষোলো"; }
            else if (minute == 17) { BanglaValue += @" সতেরো"; }
            else if (minute == 18) { BanglaValue += @" আঠারো"; }
            else if (minute == 19) { BanglaValue += @" উনিশ"; }
            else if (minute == 20) { BanglaValue += @" বিষ"; }
            else if (minute == 21) { BanglaValue += @" একুশ"; }
            else if (minute == 22) { BanglaValue += @" বাইশ"; }
            else if (minute == 23) { BanglaValue += @" তেইশ"; }
            else if (minute == 24) { BanglaValue += @" চব্বিশ"; }
            else if (minute == 25) { BanglaValue += @" পঁচিশ"; }
            else if (minute == 26) { BanglaValue += @" ছ্ছাব্বিশ"; }
            else if (minute == 27) { BanglaValue += @" সাতাইশ"; }
            else if (minute == 28) { BanglaValue += @" আঠাইশ"; }
            else if (minute == 29) { BanglaValue += @" উনত্রিশ"; }
            else if (minute == 30) { BanglaValue += @" ত্রিশ"; }
            else if (minute == 31) { BanglaValue += @" একত্রিশ"; }
            else if (minute == 32) { BanglaValue += @" বত্রিশ"; }
            else if (minute == 33) { BanglaValue += @" তেত্রিশ"; }
            else if (minute == 34) { BanglaValue += @" চৈাত্রিশ"; }
            else if (minute == 35) { BanglaValue += @" পয়ত্রিশ"; }

            else if (minute == 36) { BanglaValue += @" ছত্রিশ"; }
            else if (minute == 37) { BanglaValue += @" সাইত্রিশ"; }
            else if (minute == 38) { BanglaValue += @" আটত্রিশ"; }
            else if (minute == 39) { BanglaValue += @" উনচল্লিশ"; }
            else if (hour == 40) { BanglaValue += @" চল্লিশ"; }
            else if (minute == 41) { BanglaValue += @" একচল্লিশ"; }
            else if (minute == 42) { BanglaValue += @" বিয়াল্লিশ"; }
            else if (minute == 43) { BanglaValue += @" তেতাল্লিশ"; }
            else if (minute == 44) { BanglaValue += @" চুয়াল্লিশ"; }
            else if (minute == 45) { BanglaValue += @" পঁয়তাল্লিশ"; }
            else if (minute == 46) { BanglaValue += @" ছেঁচোল্লিশ"; }
            else if (minute == 47) { BanglaValue += @" সাতচল্লিশ"; }
            else if (minute == 48) { BanglaValue += @" আটচল্লিশ"; }

            else if (minute == 49) { BanglaValue += @" উনপন্চাশ"; }
            else if (minute == 50) { BanglaValue += @" পঞ্চাশ"; }
            else if (minute == 51) { BanglaValue += @" একান্নো"; }
            else if (minute == 52) { BanglaValue += @" বাহান্নো"; }
            else if (minute == 53) { BanglaValue += @" তিপ্পান্নো"; }
            else if (minute == 54) { BanglaValue += @" চুয়ান্নো"; }
            else if (minute == 55) { BanglaValue += @" পঞ্চান্নো"; }
            else if (minute == 56) { BanglaValue += @" ছাপ্পানো"; }
            else if (minute == 57) { BanglaValue += @" সাতান্নো"; }
            else if (minute == 58) { BanglaValue += @" আটান্নো"; }
            else if (minute == 59) { BanglaValue += @" উনষাট"; }

            #endregion
            return BanglaValue;
        }
    }

C# date to word (Bangla)

Category : 0

class DateToWord
    {
        public string ConvertEnglish()
        {
            return "";
        }

        public string ConvertBangla(DateTime dt)
        {
            int day = dt.Day;
            int month = dt.Month;
            int year = dt.Year;

            string BanglaValue = "";

            //if (day < 12)
            //{
            //    BanglaValue += @"সকাল";
            //}
            //else if (day >= 12)
            //{
            //    BanglaValue += @"দুপুর";
            //}

            #region day in bangla
            if (day == 1) { BanglaValue += @"এক"; }
            else if (day == 2) { BanglaValue += @"দুই"; }
            else if (day == 3) { BanglaValue += @"তিন"; }
            else if (day == 4) { BanglaValue += @"চার"; }
            else if (day == 5) { BanglaValue += @"পাচঁ"; }
            else if (day == 6) { BanglaValue += @"ছয়"; }
            else if (day == 7) { BanglaValue += @"সাত"; }
            else if (day == 8) { BanglaValue += @"আট"; }
            else if (day == 9) { BanglaValue += @"নয়"; }
            else if (day == 10) { BanglaValue += @"দশ"; }
            else if (day == 11) { BanglaValue += @"এগারো"; }
            else if (day == 12) { BanglaValue += @"বারো"; }

            else if (day == 13) { BanglaValue += @" তেরো"; }
            else if (day == 14) { BanglaValue += @" চৈাদ্দো্"; }
            else if (day == 15) { BanglaValue += @" পনেরো"; }
            else if (day == 16) { BanglaValue += @" ষোলো"; }
            else if (day == 17) { BanglaValue += @" সতেরো"; }
            else if (day == 18) { BanglaValue += @" আঠারো"; }
            else if (day == 19) { BanglaValue += @" উনিশ"; }
            else if (day == 20) { BanglaValue += @" বিষ"; }
            else if (day == 21) { BanglaValue += @" একুশ"; }
            else if (day == 22) { BanglaValue += @" বাইশ"; }
            else if (day == 23) { BanglaValue += @" তেইশ"; }
            else if (day == 24) { BanglaValue += @" চব্বিশ"; }
            else if (day == 25) { BanglaValue += @" পঁচিশ"; }
            else if (day == 26) { BanglaValue += @" ছ্ছাব্বিশ"; }
            else if (day == 27) { BanglaValue += @" সাতাইশ"; }
            else if (day == 28) { BanglaValue += @" আঠাইশ"; }
            else if (day == 29) { BanglaValue += @" উনত্রিশ"; }
            else if (day == 30) { BanglaValue += @" ত্রিশ"; }
            else if (day == 31) { BanglaValue += @" একত্রিশ"; }
            #endregion

            /*
             * জানুয়ারি ফেব্রুয়ারি মার্চ এপ্রিল মে জুন জুলাই আগস্ট সেপেট্মবর অক্টো্বর নভেম্বর ডিসেম্বর
             * */
            #region month in bangla
            if (month == 1) { BanglaValue += @" জানুয়ারি"; }
            else if (month == 2) { BanglaValue += @" ফেব্রুয়ারি"; }
            else if (month == 3) { BanglaValue += @" মার্চ"; }
            else if (month == 4) { BanglaValue += @" এপ্রিল"; }
            else if (month == 5) { BanglaValue += @" মে"; }
            else if (month == 6) { BanglaValue += @" জুন"; }
            else if (month == 7) { BanglaValue += @" জুলাই"; }
            else if (month == 8) { BanglaValue += @" আগস্ট"; }
            else if (month == 9) { BanglaValue += @" সেপেট্মবর"; }
            else if (month == 10) { BanglaValue += @" অক্টো্বর"; }
            else if (month == 11) { BanglaValue += @" নভেম্বর"; }
            else if (month == 12) { BanglaValue += @" ডিসেম্বর"; }
            #endregion

            /*
             * ২০১০ ২০১১ ২০১২ ২০১৩ ২০১৪ ২০১৫ ২০১৬ ২০১৭ ২০১৮ ২০১৯ ২০২০
             * */
            #region year in bangla
            if (year == 2010) { BanglaValue += @" ২০১০"; }
            else if (year == 2011) { BanglaValue += @" ২০১১"; }
            else if (year == 2012) { BanglaValue += @" ২০১২"; }
            else if (year == 2013) { BanglaValue += @" ২০১৩"; }
            else if (year == 2014) { BanglaValue += @" ২০১৪"; }
            else if (year == 2015) { BanglaValue += @" ২০১৫"; }
            else if (year == 2016) { BanglaValue += @" ২০১৬"; }
            else if (year == 2017) { BanglaValue += @" ২০১৭"; }
            else if (year == 2018) { BanglaValue += @" ২০১৮"; }
            else if (year == 2019) { BanglaValue += @" ২০১৯"; }
            else if (year == 2020) { BanglaValue += @" ২০২০"; }
            else if (year == 2021) { BanglaValue += @" ২০২১"; }
            #endregion

            return BanglaValue;
        }
    }

ASP.NET Image Uploader Class example

Thursday, January 17, 2013 Category : 0

  <p align="center">
                        <asp:Image ID="Image1" runat="server" Height="105px"
                            ImageUrl="~/Images/default.gif" Width="135px" /><br />
                        <asp:Label ID="lblUploadStatus" runat="server" Text=""></asp:Label>
                        <asp:FileUpload ID="FileUpload1" runat="server" /><br />
                        <asp:LinkButton ID="LinkButton1"
                            runat="server" onclick="LinkButton1_Click">Upload</asp:LinkButton>
                            <br />
                          
                        <asp:Button ID="btnChangeImage" runat="server" Text="Change"
                            onclick="btnChangeImage_Click" />
                    </p>

public class Uploader : System.Web.UI.Page
    {
        public string UploadItemImage(FileUpload fileUpload)
        {
            string filePath = "";
            if (fileUpload.HasFile)
            {
                if (CheckFileType(fileUpload))
                {
                    string postedLogo = fileUpload.PostedFile.FileName.ToString();
                    string fileName = postedLogo.Split(new char[] { '\\' }).Last();
                    MembershipUser mu = Membership.GetUser();
                    string fileExtension = fileUpload.PostedFile.FileName.Split(new char[] { '.' }).Last().ToLower();
                    filePath = "~/ItemImages/" + fileUpload.FileName.Replace(fileName, mu.UserName + "." + fileExtension);


                    string filename = mu.UserName + "." + fileExtension;

                    try
                    {
                        System.Drawing.Image UploadedImage = System.Drawing.Image.FromStream(fileUpload.PostedFile.InputStream);


                        if (System.IO.File.Exists(Server.MapPath(filePath)))
                        {
                            System.IO.File.Delete(Server.MapPath(filePath));
                        }

                        ResizeImage(filename, fileUpload);

                        Session["imgPathItem"] = filePath;
                        return filePath;
                    }
                    catch (Exception ex)
                    {
                        Session["ex"] = ex.Message;
                    }
                }
                else
                {

                    return "";

                }
            }
            else
            {
                return "";

            }
            return "";
        }


        private void ResizeImage(string filename,FileUpload fileUpload)
        {

            if (!Directory.Exists(Server.MapPath(@"~/ItemImages")))
                {
                    Directory.CreateDirectory(Server.MapPath(@"~/ItemImages"));
                }
                string directory = Server.MapPath(@"~/ItemImages/") + filename;
                Bitmap originalBMP = new Bitmap(fileUpload.FileContent);
                int origWidth = originalBMP.Width;
                int origHeight = originalBMP.Height;
                int sngRatio = ((int)(origWidth / origHeight) == 0) ? 1 : (origWidth / origHeight);
                int newWidth = 150;
                int newHeight = newWidth / sngRatio;
                Bitmap newBMP = new Bitmap(originalBMP, newWidth, newHeight);
                Graphics oGraphics = Graphics.FromImage(newBMP);

                oGraphics.SmoothingMode = SmoothingMode.AntiAlias; oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;

                oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                newBMP.Save(directory, ImageFormat.Jpeg);
              
                originalBMP.Dispose();
                newBMP.Dispose();
                oGraphics.Dispose();
           
          
        }

        public bool SaveFinalFile(string fileLoc, string newFileName)
        {
            try
            {
                if (File.Exists(Server.MapPath(fileLoc)))
                {
                    string newFileLocation = Server.MapPath(@"~/ItemImages/") + newFileName + "." + Session["imageExtensition"].ToString();
                    File.Copy(Server.MapPath(fileLoc), newFileLocation,true);
                    Session["imgPathItem"] = @"~/ItemImages/" + newFileName + "." + Session["imageExtensition"].ToString();
                    return true;
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return false;
        }

        private bool CheckFileType(FileUpload fileUpload)
        {
            string[] fileTypeList = { "jpeg", "jpg", "gif", "bmp", "png" };
            string fileExtension = fileUpload.PostedFile.FileName.Split(new char[] { '.' }).Last().ToLower();
            bool flag = false;
            for (int i = 0; i < fileTypeList.Count(); i++)
            {
                if (fileExtension == fileTypeList[i])
                {
                    flag = true;
                    Session["imageExtensition"] = fileExtension;
                    break;
                }
            }
            if (flag)
            {
                return true;
            }
            return false;
        }

    }

Powered by Blogger.