Pages

Subscribe:

Sunday, 30 August 2015

Resignation letter Sample

Dear xxx ,

Please accept this letter of resignation from the position of
Technical Lead, 30 days from today. My last day at [Company Name]will be
29-Sep-2015.

I have accepted a position with another company that will further my
growth and development in my career. I have enjoyed working at [Company Name]
and will miss my colleagues. However, this new position will challenge
my growth and further my career.

During the next one month, I am willing to help you in any way to make
the transition as smooth as possible. This includes assisting in
recruiting and training my replacement. Please let me know if there is
anything specific that you would like me to do.

Again, it has been a pleasure working as a part of your company.

Best regards,

Manish Kumar Srivastava

Thursday, 26 February 2015

Autocomplete on masterpage

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
    <asp:TextBox ID="txtAutoComplete" runat="server" />
    <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" DelimiterCharacters=""
        Enabled="True" ServicePath="SaveSelectedOption.asmx" ServiceMethod="GetCompletionList"
        TargetControlID="txtAutoComplete" MinimumPrefixLength="1" CompletionInterval="10"
        EnableCaching="true" CompletionSetCount="12">
    </asp:AutoCompleteExtender>

 [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            if (count == 0)
            {
                count = 10;
            }
            DataTable dt = GetRecords(prefixText);
            List<string> items = new List<string>(count);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string strName = dt.Rows[i][0].ToString();
                items.Add(strName);
            }
            return items.ToArray();
        }

        public DataTable GetRecords(string strName)
        {
            string strConn = ConfigurationManager.ConnectionStrings["jsupportconnectionstring"].ConnectionString;
            SqlConnection con = new SqlConnection(strConn);
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = con;
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.Parameters.AddWithValue("@Name", strName);
            cmd.CommandText = "select CommentEmpId from LT_CommentReadHistory where CommentEmpId like '%'+@Name+'%'";
            DataSet objDs = new DataSet();
            SqlDataAdapter dAdapter = new SqlDataAdapter();
            dAdapter.SelectCommand = cmd;
            con.Open();
            dAdapter.Fill(objDs);
            con.Close();
            return objDs.Tables[0];
        }
using System.Configuration;
using System.Data.SqlClient;

Sunday, 8 February 2015

Save data through XML

 StringBuilder objBuilder = GetCheckedSitemap();
Role objRole = new Role();
          objRole.AddedBy = "admin";
          objRole.LastModBy = "admin";
          objRole.RoleID = roleID;
          objRole.XMLData = objBuilder.ToString();

 private StringBuilder GetCheckedSitemap()
    {
    
        StringBuilder objBuilder = new StringBuilder();
        objBuilder.Append("<?xml version=\"1.0\"?>");
        objBuilder.Append("<Root>");
  objBuilder.Append("<sitemaprole roleid=\"" + roleID + "\" SiteMapID=\"" + row1["NavId"] + "\"/>");
   objBuilder.Append("</Root>");

        return objBuilder;
    }

proc
@XMl xml=null


 update tblUwkrn  set flow= flow+ '','' + @flow
                         ,StaffId=@StaffId
                         ,StaffDate=GETDATE()
                         ,StaffStatus=@StaffStatus
                         ,AsmStatus=@AsmStatus
         from tblUwkrn inner join
         @XMl.nodes(''UwkrnList'')r(item)
        on tblUwkrn.uwkrn=item.value(''@UwkrnNo'',''nvarchar(100)'')               
       and eventid=@EventId and AsmId=@AsmId and confirm_status=''Yes''

CREATE PROCEDURE[dbo].[usp_ADM_SaveSiteMapRole]
(
   
    @RoleID varchar(50),
   
    @XMLData varchar(max),
    @AddedBy varchar(50),
    @LastModBy varchar(50),
    @EventId nvarchar(50)
)

AS
BEGIN

BEGIN TRAN SaveSiteMapRole
 BEGIN TRY
   
    DECLARE @hDoc int
    DECLARE @Error int   

    EXEC sp_xml_preparedocument @hDoc OUTPUT,@XMLData

    DELETE FROM ADM_SiteMapRole
    WHERE RoleID=@RoleID and EventId=@EventId

    SELECT @EventId as eventId, roleid,sitemapid,1 as IsActive,@AddedBy as AddedBy,GETDATE() as AddedDTM,
        @LastModBy as LastModBy,GETDATE() as LastModDTM
    INTO #ADM_SiteMapRole
    FROM OpenXML(@hDoc,''/Root/sitemaprole'')
    WITH (
            roleid varchar(50) ''@roleid'',
            sitemapid int ''@SiteMapID''       
         )
       
         declare
         @eventId1 varchar(50),
         @roleid1 varchar(50),
         @sitemapid1 int,       
         @IsActive1 bit,
         @AddedBy1 varchar(50),
         @AddedDTM1 datetime,
         @LastModBy1 varchar(50),
         @LastModDTM1 datetime
       
       
        DECLARE sr_cursor CURSOR LOCAL FOR
            SELECT eventId,roleid,sitemapid,IsActive,AddedBy,AddedDTM,LastModBy,LastModDTM
            FROM #ADM_SiteMapRole                
        OPEN sr_cursor;
        FETCH NEXT FROM sr_cursor INTO @eventId1, @roleid1,@sitemapid1,@IsActive1,@AddedBy1,@AddedDTM1,@LastModBy1,@LastModDTM1
            WHILE @@FETCH_STATUS = 0
            BEGIN
                --login here
                if not exists(select 1 from ADM_SiteMapRole where RoleID=@roleid1 and SiteMapID=@sitemapid1 and IsActive=@IsActive1 and EventId= @eventId1)
                begin
                    --insert
                    INSERT INTO ADM_SiteMapRole(EventId,RoleID,SiteMapID,IsActive,AddedBy,AddedDTM,LastModBy,LastModDTM)
                    SELECT @eventId1, @roleid1,@sitemapid1,@IsActive1,@AddedBy1,@AddedDTM1,@LastModBy1,@LastModDTM1
                    --find all parent id and insert for them 
                    declare @t1  as table
                    (
                        id int not null identity(1,1),
                        sitemapid int,
                        parentid int                   
                    )
                   
                    insert into @t1(sitemapid,parentid )
                    select sitemapid,parentid
                    from dbo.func_ADM_GetParentsOfId(@sitemapid1, @eventId1) where sitemapid <> @sitemapid1
                   
                    declare @count int
                    declare @sid int
                    set @count=1
                    while ( @count <= (select MAX(id) from @t1) )
                    begin                   
                        select @sid=sitemapid from @t1 where id=@count
                        if not exists(select 1 from ADM_SiteMapRole where RoleID=@roleid1 and SiteMapID=@sid and IsActive=@IsActive1 and EventId=@eventId1)
                        begin
                            INSERT INTO ADM_SiteMapRole(EventId,RoleID,SiteMapID,IsActive,AddedBy,AddedDTM,LastModBy,LastModDTM)
                            SELECT @eventId1, @roleid1,@sid,@IsActive1,@AddedBy1,@AddedDTM1,@LastModBy1,@LastModDTM1
                        end                       
                        set @count = @count + 1
                    end     
                end               
                FETCH NEXT FROM sr_cursor INTO @eventId1, @roleid1,@sitemapid1,@IsActive1,@AddedBy1,@AddedDTM1,@LastModBy1,@LastModDTM1
            END
        CLOSE sr_cursor;
        DEALLOCATE sr_cursor;      

    --ERROR HANDLER
    SET @Error = @@error
    IF (@Error <> 0)
    BEGIN
        exec sp_xml_removedocument @hDoc
        RETURN
    END   

    drop table #ADM_SiteMapRole
    exec sp_xml_removedocument @hDoc
   
    COMMIT TRAN SaveSiteMapRole
 end Try
 BEGIN CATCH

 ROLLBACK TRAN SaveSiteMapRole
 close  SaveSiteMapRole
 SELECT ERROR_LINE(),ERROR_NUMBER(),ERROR_SEVERITY(),ERROR_STATE(),ERROR_PROCEDURE()
,ERROR_MESSAGE()
 END CATCH

END

Thursday, 29 January 2015

Change label into textbox using jquery

<div>
    <div id="tagCust">Customer Details<img src="images/edit.png" class="alignright"/></div>
</div>

<div id="contactdetail">
    <div id="contactInfo">
        <label for="emailid" class="contactText" data-inline="true">Email Id*</label>
    </div>
         <label for="mobileno" class="contactText" data-inline="true">Mobile No.</br></label>
         <label for="custid" class="contactText" data-inline="true">Customer Id.</label>
</div>
 
$('.alignright').on('click', function() {
    $('label.contactText').slice(0,2).each(function() {
        $(this).replaceWith( '<input type="text"/>' );
    });
});
 
$("label").each(function(){
        if(($(this).attr("for") == "emailid")||($(this).attr("for") == "mobileno")){
           $(this).after("<input type='text' id='"+ $(this).attr("for") +"'/>");
           $(this).hide();
        }
    });  

Sunday, 18 January 2015

Upload PDF

  FileUpload fl1 = (FileUpload)pnl2.FindControl("FileUpload2");
                UploadImage(fl1);
                sPath1 = UploadImage(fl1);
                if (sPath1 == "File size cannot be larger than 2 MB")
                {
                    lblSuccess.Text = sPath1;
                    return;
                }

 private string UploadImage(FileUpload fl)
    {
        string sSavePath = string.Empty;
        string sSavePath1 = string.Empty;
        string sFilename = string.Empty;
        string msg = string.Empty;
        Random RandomClass = new Random();
        int RandomNumber1 = RandomClass.Next(1000, 9000);

        // Set constant values
        string type = fl.PostedFile.ContentType;

        //code for jpg file
        if (fl.HasFile && checkImageContentType(fl.PostedFile.ContentType))
        {
            // HttpPostedFile fl = fl.PostedFile;
            if (fl.PostedFile.ContentType != "application/pdf")
            {
                System.Drawing.Image oImage = System.Drawing.Image.FromStream(fl.PostedFile.InputStream);
                if (oImage.Width > 150 || oImage.Height > 150)
                {
                    lblSuccess.Text = "Image is greater than 150 * 150";
                    completepath = lblSuccess.Text.ToString();
                    return completepath;
                }
                else
                {
                    sSavePath = "Brochure/";
                    sFilename = fl.FileName;
                    sFilename = "Press" + Convert.ToString(Session["exid"]) + RandomNumber1 + "_" + fl.FileName;
                    fl.SaveAs(Server.MapPath(sSavePath + sFilename));
                    completepath = sSavePath + sFilename;
                    return completepath;
                }
            }
            else
            {
                if (((Convert.ToDecimal(fl.PostedFile.ContentLength) / 1024) / 1024) > 2)
                {

                    lblSuccess.Text = "File size cannot be larger than 2 MB";
                    return lblSuccess.Text;
                }
                else
                {
                    sSavePath = "PDF/";
                    sFilename = "Press_" + Convert.ToString(Session["exid"]) + RandomNumber1 + "_" + fl.FileName;
                    fl.SaveAs(Server.MapPath(sSavePath + sFilename));
                    completepath = sSavePath + sFilename;
                    return completepath;
                }
            }
        }
        else
        {
            return msg;
        }
    }
    public static bool checkImageContentType(string contentType)
    {
        //check whether the uploaded file is an image or not
        if (contentType == "image/gif" || contentType == "image/jpeg" || contentType == "image/pjpeg" || contentType == "application/pdf")
            return true;
        else
            return false;
    }

 <asp:FileUpload ID="FileUpload2" runat="server" />
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="FileUpload2"
                                            ErrorMessage="Required" Display="Dynamic">Required</asp:RequiredFieldValidator><br />
                                        <asp:RegularExpressionValidator ID="RevDoc" runat="server" ControlToValidate="FileUpload2"
                                            ErrorMessage="select only PDF file." ValidationExpression="^.+(.pdf)$" Display="Dynamic"><span style="color: Red">select only PDF file</span> </asp:RegularExpressionValidator>
                                        <a id="Pdf" target="_blank" runat="server"></a><span id="err2" style="color: Red">

Find Row Index in gridView

 DataKeyNames="id"
<Columns>
                                                <asp:TemplateField HeaderText="NO." HeaderStyle-HorizontalAlign="Left" Visible="false">
                                                    <ItemTemplate>
                                                        <asp:Label ID="lblSNo" runat="server" Text='<%# Eval("SrNo")%>'></asp:Label>
                                                        <asp:Label ID="hdSeq" runat="server" Text='<%# Eval("ItemOrder")%>' Visible="false" />
                                                    </ItemTemplate>
                                                    <ItemStyle HorizontalAlign="Left" />
                                                </asp:TemplateField>
                                                <asp:BoundField DataField="Press_Title" HeaderText="Press Release" HeaderStyle-HorizontalAlign="Left"
                                                    ItemStyle-HorizontalAlign="Left" />
                                                <%--<asp:ButtonField CommandName="edt" HeaderText="Edit" Text="Edit" HeaderStyle-HorizontalAlign="Left" />--%>
                                                <asp:TemplateField HeaderText="Edit" HeaderStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="btnedit" runat="server" CommandName="edt" CommandArgument='<%# Eval("specialid") %>'
                                                            CausesValidation="False">Edit</asp:LinkButton>
                                                    </ItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Center" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Status">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="LinkButton1" runat="server" Text='<%# Eval("Press_status") %>'
                                                            CommandName="Change" CommandArgument='<%# Eval("specialid") %>' CausesValidation="False"
                                                            OnClick="LinkButton1_Click"></asp:LinkButton>
                                                    </ItemTemplate>
                                                    <HeaderStyle HorizontalAlign="Left" />
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Up" HeaderStyle-Width="10%" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="lnkup" CausesValidation="false" runat="server" CommandName="Up"
                                                            Visible="false">
                                                            <asp:Image ID="imgUp" runat="server" ImageUrl="images/up_red.gif" />
                                                        </asp:LinkButton>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Down" HeaderStyle-Width="10%" HeaderStyle-HorizontalAlign="Left">
                                                    <ItemTemplate>
                                                        <asp:LinkButton ID="lnkdown" CausesValidation="false" runat="server" CommandName="Down"
                                                            Visible="false">
                                                            <asp:Image ID="imgDown" runat="server" ImageUrl="images/down_red.gif" />
                                                        </asp:LinkButton>
                                                    </ItemTemplate>
                                                </asp:TemplateField>
                                            </Columns>

 protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton lb1 = (LinkButton)sender;
        GridViewRow row = (GridViewRow)lb1.NamingContainer;
        Session["Index"] = row.RowIndex;
    }



if (e.CommandName == "edt" || e.CommandName == "Change" || e.CommandName == "Up" || e.CommandName == "Down")
            {
                GridViewRow row = (GridViewRow)((Control)e.CommandSource).NamingContainer;

                int index = Convert.ToInt32(row.RowIndex);
                string sProdId = GridView1.DataKeys[index].Value.ToString();
                if (e.CommandName == "Change")
                {
                    Session["spcloffer"] = e.CommandArgument;
                }
                else if (e.CommandName == "edt")
                {
                    Session["spcloffer"] = Convert.ToString(e.CommandArgument);
                    using (SqlCommand cmd = new SqlCommand("Sp_ManageExhibitorPress", Conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        using (SqlDataAdapter da = new SqlDataAdapter())
                        {
                            da.SelectCommand = cmd;
                            da.SelectCommand.Parameters.AddWithValue("@eventid", Session["eventid"].ToString());
                            da.SelectCommand.Parameters.AddWithValue("@exid", Convert.ToString(Session["exid"]));
                            da.SelectCommand.Parameters.AddWithValue("@specialId", Convert.ToString(Session["spcloffer"]));
                            da.SelectCommand.Parameters.AddWithValue("@flag", "GRID_MODIFY");
                            da.SelectCommand.Parameters.AddWithValue("@RecordCount", 0);
                            da.SelectCommand.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
                            //Response.Write("test-" + Session["eventid"].ToString() + "-" + Session["exid"].ToString() + "-" + Convert.ToString(Session["spcloffer"]));
                            using (DataTable dt = new DataTable())
                            {
                                da.Fill(dt);
                                if (dt != null && dt.Rows.Count > 0)
                                {
                                    lblSuccess.Text = "";
                                    txtProductName.Text = dt.Rows[0]["Press_Title"].ToString();
                                    txtProductDescription.Text = dt.Rows[0]["Press_desc"].ToString();
                                    if (!string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["Press_pdf"])))
                                    {
                                        Pdf.HRef = Convert.ToString(dt.Rows[0]["Press_pdf"]);
                                        Pdf.InnerText = "View";
                                    }


                                }
                                btnSubmit.Visible = false;
                                btnUpdate.Visible = true;
                            }
                        }
                    }
                }

                switch (e.CommandName.ToLower())
                {

                    case "change":

                        LinkButton lb = (LinkButton)GridView1.Rows[Convert.ToInt32(Session["Index"].ToString())].Cells[0].FindControl("LinkButton1");
                        string status = string.Empty;
                        if (lb.Text == "Valid")
                        {
                            status = "Invalid";
                        }
                        else
                        {
                            status = "Valid";
                        }
                        using (SqlCommand cmd = new SqlCommand("Sp_ManageExhibitorPress", Conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.AddWithValue("@specialId", Convert.ToString(Session["spcloffer"]));
                            cmd.Parameters.AddWithValue("@eventid", Session["eventid"].ToString());
                            cmd.Parameters.AddWithValue("@exid", Session["exid"].ToString());
                            cmd.Parameters.AddWithValue("@special_status", status);
                            cmd.Parameters.AddWithValue("@flag", "UPDATE_STATUS");
                            cmd.Parameters.AddWithValue("@RecordCount", 0);
                            cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
                            Conn.Open();
                            cmd.ExecuteNonQuery();
                            if (cmd.Parameters["@RecordCount"].Value != DBNull.Value)
                            {
                                Conn.Close();
                                lblSuccess.Text = "Records Modified Successfully!";
                            }
                            else
                            {
                                lblSuccess.Text = "Seems Some Problem! Please try again later.";
                            }
                        }
                        break;
                    case "up":
                        {
                            Label Newhd = (Label)GridView1.Rows[index - 1].FindControl("hdSeq");
                            Label hd = (Label)GridView1.Rows[index].FindControl("hdSeq");
                            int NewSeqno = Convert.ToInt32(Newhd.Text);
                            int Seqno = Convert.ToInt32(hd.Text);
                            string sNewProdId = GridView1.DataKeys[index - 1].Value.ToString();
                            using (SqlCommand cmd = new SqlCommand("Sp_ManageExhibitorPress", Conn))
                            {
                                ///<summary>
                                ///this procedure uses table tblProds to update the order in the
                                /// products will be displayed for this exhibitors
                                ///</summary>
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.AddWithValue("@eventid", Session["eventid"].ToString());
                                cmd.Parameters.AddWithValue("@exid", Session["exid"].ToString());
                                cmd.Parameters.AddWithValue("@sequenceNo", Seqno);
                                cmd.Parameters.AddWithValue("@newSequenceNo", NewSeqno);
                                cmd.Parameters.AddWithValue("@specialId", sProdId);
                                cmd.Parameters.AddWithValue("@newspecialId", sNewProdId);
                                cmd.Parameters.AddWithValue("@flag", "GRID_UP");
                                cmd.Parameters.AddWithValue("@RecordCount", 0);
                                cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
                                Conn.Open();
                                cmd.ExecuteNonQuery();
                                Conn.Close();
                            }
                        }
                        break;
                    case "down":
                        {
                            Label Newhd = (Label)GridView1.Rows[index + 1].FindControl("hdSeq");
                            Label hd = (Label)GridView1.Rows[index].FindControl("hdSeq");
                            int NewSeqno = Convert.ToInt32(Newhd.Text);
                            int Seqno = Convert.ToInt32(hd.Text);
                            string sNewProdId = GridView1.DataKeys[index + 1].Value.ToString();
                            using (SqlCommand cmd = new SqlCommand("Sp_ManageExhibitorPress", Conn))
                            {
                                ///<summary>
                                ///this procedure uses table tblProds to update the order in the
                                /// products will be displayed for this exhibitors
                                ///</summary>
                                cmd.CommandType = CommandType.StoredProcedure;
                                cmd.Parameters.AddWithValue("@eventid", Session["eventid"].ToString());
                                cmd.Parameters.AddWithValue("@exid", Session["exid"].ToString());
                                cmd.Parameters.AddWithValue("@sequenceNo", Seqno);
                                cmd.Parameters.AddWithValue("@newSequenceNo", NewSeqno);
                                cmd.Parameters.AddWithValue("@specialId", sProdId);
                                cmd.Parameters.AddWithValue("@newspecialId", sNewProdId);
                                cmd.Parameters.AddWithValue("@flag", "GRID_UP");
                                cmd.Parameters.AddWithValue("@RecordCount", 0);
                                cmd.Parameters["@RecordCount"].Direction = ParameterDirection.Output;
                                Conn.Open();
                                cmd.ExecuteNonQuery();
                                Conn.Close();
                            }
                        }
                        break;
                }
                BindGridData();
            }
        }