Monday, October 21, 2013

Check Existing record by join two tables using Linq

//Use this code to check existing record from two tables using Linq .

Chrome_VINEquipment existequipment = db.Chrome_VINEquipments.Where(x => x.VINPatternID == VinPatternID && db.WS_GenericEquipments.Any(c => c.StyleId == car.StyleId)).FirstOrDefault();

Monday, July 8, 2013

Find Item in DropDownlist


Find Item in dropdown if item find then selected or its ignored .with this code.....
ddlBody.SelectedIndex = ddlBody.Items.IndexOf(ddlBody.Items.FindByValue(Convert.ToString(lst[0].BodyId)));

Tuesday, June 25, 2013

Update row by row any field without cursor



WITH myTable2 AS
    (
    SELECT vinid, ROW_NUMBER() OVER (ORDER BY vinid) AS sequence
    FROM VehicleDescription
    )
   


UPDATE genericequipment
SET VinID = VehicleDescription.vinid
FROM VehicleDescription
JOIN genericequipment on VehicleDescription.VinPattern = genericequipment.vinPattern;

Saturday, March 9, 2013

Custom Paging in Datalist or repeater


This is a very simple custom paging technique for a developer where ha can do paging in datalist and repeater in only 5 minutes.enjoy code.....

  public void BindPhoto()
        {
            GalleryModuleController objCommentModules = new GalleryModuleController();

            List cmi;
            cmi = objCommentModules.PhotoList(0);
            if (cmi.Count > 0)
            {
                dlphotogallery.DataSource = cmi;
                dlphotogallery.DataBind();
                pds.DataSource = cmi;
                pds.AllowPaging = true;

                //to set the paging change the number 3 to your desired value

                pds.PageSize = 4;

                pds.CurrentPageIndex = CurrentPage;

                lnkbtnNext.Enabled = !pds.IsLastPage;

                lnkbtnPrevious.Enabled = !pds.IsFirstPage;

                dlphotogallery.DataSource = pds;

                dlphotogallery.DataBind();

                doPaging();
            }
        }


        protected void lnkbtnPrevious_Click(object sender, EventArgs e)
        {

            CurrentPage -= 1;
            BindPhoto();

        }

        protected void lnkbtnNext_Click(object sender, EventArgs e)
        {

            CurrentPage += 1;

            BindPhoto();

        }

        protected void dlPaging_ItemCommand(object source, DataListCommandEventArgs e)
        {

            if (e.CommandName.Equals("lnkbtnPaging"))
            {
                CurrentPage = Convert.ToInt16(e.CommandArgument.ToString());
                BindPhoto();
            }

        }

        protected void dlPaging_ItemDataBound(object sender, DataListItemEventArgs e)
        {

            LinkButton lnkbtnPage = (LinkButton)e.Item.FindControl("lnkbtnPaging");
            if (lnkbtnPage.CommandArgument.ToString() == CurrentPage.ToString())
            {
                lnkbtnPage.Enabled = false;
                lnkbtnPage.Font.Bold = true;
            }

        }

        public int CurrentPage
        {
            get
            {
                if (this.ViewState["CurrentPage"] == null)

                    return 0;

                else

                    return Convert.ToInt16(this.ViewState["CurrentPage"].ToString());

            }

            set
            {

                this.ViewState["CurrentPage"] = value;

            }

        }



        private void doPaging()
        {

            DataTable dt = new DataTable();

            dt.Columns.Add("PageIndex");

            dt.Columns.Add("PageText");

            for (int i = 0; i < pds.PageCount; i++)
            {

                DataRow dr = dt.NewRow();

                dr[0] = i;

                dr[1] = i + 1;

                dt.Rows.Add(dr);

            }

            dlPaging.DataSource = dt;

            dlPaging.DataBind();

        }

Open PopUp using jquery css and jqeury code.

This is the open popup code using jquery with appplying css .this is a very simple and attractive pop up window just applied on div.

 $(document).ready(function () {
        $('open').click(function () {
            alert('hi');
            load();
        });

        $('.close').click(function () {
            unload();

        });
    });


 function unload() {    // TO Unload the Popupbox

        $('.popup').fadeOut("slow");
        $("#container").css({ // this is just for style      
            "opacity": "1"
        });
    }

    function load() {    // To Load the Popupbox
        $('.popup').fadeIn("slow");
        $("#container").css({ // this is just for style
            "opacity": "0.3"
        });

    }


style type="text/css"
    .popup {
        display: none; /* Hide the DIV */
        position: absolute;
        _position: absolute; /* hack for internet explorer 6 */
        height: 325px;
        width: 325px;
        background: #FFFFFF;
        left: 80px;
        top: 100px;
        z-index: 100; /* Layering ( on-top of others), if you have lots of layers: I just maximized, you can change it yourself */
        margin-left: 15px;
        /* additional features, can be omitted */
        border:2px solid #ff0000;
        padding:15px;
        font-size: 15px;
        -moz-box-shadow: 0 0 5px #ff0000;
        -webkit-box-shadow: 0 0 5px #ff0000;
        box-shadow: 0 0 5px #ff0000;
     
    }
 
    #container {
        width: 100%;
        height: 100%;
    }

    a {
        cursor: pointer;
        text-decoration: none;
    }

    /* This is for the positioning of the Close Link */
    #popupBoxClose {
        font-size: 20px;
        line-height: 15px;
        right: 5px;
        top: 5px;
        position: absolute;
        color: #6fa5e2;
        font-weight: 500;
    }
   /style

Tuesday, February 26, 2013

Send mail comman code


public static void Send(string[] To, String Subject, String Body,bool IsBodyHtml)
    {
        try
        {
            var smtp = new SmtpClient
            {
                Host = Host,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(SMTPUser, Password),
            };

            var message = new MailMessage()
            {
                Subject = Subject,
                Body = Body
            };

            foreach (var vv in (from s in To select (new MailAddress(s))))
            {
                message.To.Add(vv);
            }
           
            message.From = new MailAddress(From);
            message.IsBodyHtml = IsBodyHtml;
            smtp.Send(message);
        }
        catch
        {
        }
    }

Wednesday, February 13, 2013

Remove item from array list of multiple column.


This problem occured when i was doing project in dotnetnuke 5.6.3 so in arraylist there have multiple columns and I and remove row which contains particular value of type.this is the code for solve this problem.

DotNetNuke.Entities.Users.UserController oUserController = new DotNetNuke.Entities.Users.UserController();
           
            ArrayList listroles = oUserController.GetUsers(this.PortalId, true, true);
            int j = 0;

            for (int i = 0; i < listroles.Count; i++)
            {
                DotNetNuke.Entities.Users.UserInfo info = (DotNetNuke.Entities.Users.UserInfo)listroles[i];
                if (info.Username == UserInfo.Username)
                {
                    listroles.Remove(info);
                }
            }

Tuesday, January 22, 2013

Split function in sql server


I have created a function for spliting the string of any type with the required delimeter which you want to specify hope so this function will solve your splitting problem in sql server.

CREATE FUNCTION dbo.fnSplit(
    @sInputList VARCHAR(8000) -- List of delimited items
  , @sDelimiter VARCHAR(8000) = ',' -- delimiter that separates items
) RETURNS @List TABLE (item VARCHAR(8000))

BEGIN
DECLARE @sItem VARCHAR(8000)
WHILE CHARINDEX(@sDelimiter,@sInputList,0) <> 0
 BEGIN
 SELECT
  @sItem=RTRIM(LTRIM(SUBSTRING(@sInputList,1,CHARINDEX(@sDelimiter,@sInputList,0)-1))),
  @sInputList=RTRIM(LTRIM(SUBSTRING(@sInputList,CHARINDEX(@sDelimiter,@sInputList,0)+LEN(@sDelimiter),LEN(@sInputList))))

 IF LEN(@sItem) > 0
  INSERT INTO @List SELECT @sItem
 END

IF LEN(@sInputList) > 0
 INSERT INTO @List SELECT @sInputList -- Put the last item in
RETURN
END
GO

Tuesday, January 8, 2013

Write Div Content on new window


We want to open new window and write content on it which we want to write into it.
$("#adv").click(function () {
            var html = $("#dvcontent").html();
            var w = window.open();
            w.document.writeln(html);
       });

Monday, January 7, 2013

Integrate Google Map into our MVC application


This is the code for integrating google map into our all types application just u paste this code and pass the longitude and latitude into function it ll automtically take the location and show ur desired place to u and you can manage it urself as u want.enjoy.....
script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAVc
JQrx7VsumiP2heFwp
6URQLaiSrhXTkLq3m
A9rOmHpVsHwBjxT
g7C5-XXHl634dCROpHwK
MO9BzmQ&sensor=true_or_false"
            type="text/javascript" script




    script type="text/javascript"

        function initialize() {
            if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map_canvas"));
                map.setCenter(new GLatLng(20.593684, 78.96288), 13);
                map.setUIToDefault();
            }
        }

   script

  body onload="initialize()" onunload="GUnload()"
    div id="map_canvas" style="width: 500px; height: 300px">
  body