Tuesday, June 24, 2014

Alter colliation conflicts in SQL

 
      ALTER TABLE dbo.warrant_payments ALTER COLUMN ChequeNo
            varchar(36)COLLATE SQL_Latin1_General_CP1_CS_AS  NULL;

Monday, May 26, 2014

Refresh Parent Window On Closing Of Child Window

<script language="javascript" type="text/javascript">
 function closeAddcostpopup(warrantid) {
   
        if (window.opener && !window.opener.closed)
        {
         
            if (warrantid != "") {
                window.opener.location.href = "EditViewReport.aspx?WarrantID=" + warrantid;
                window.close();
            }
   
        }
}
        </script>

on page load use below code:

 this.btnclose.Attributes.Add("OnClick", "javascript:return  closeAddcostpopup(" + hidden1 + ")");

Open pop up window from link button in gridview,datalist,repeater etc

<asp:Repeater ID="RPVisitdetails" runat="server" >
<HeaderTemplate>
<table   cellpadding="0" cellspacing="0" border="0" class="border_table"  Width="100%">
 <tr>
                                                            <td class="tdPurpleDarkE" colspan="2">
                                                                PREVIOUS VISIT INFORMATION</td>
                                                        </tr>

</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="padding-left:5px;"><br />
<b><asp:Label ID="Label29" runat="server" Text='<%#Eval("visittxtnum") %>'/>&nbsp;&nbsp; <asp:Label ID="lbladd" runat="server" Text='<%#Eval("visitreport") %>'/></b></td>
<td style="text-align:right;padding-right:10px;">
<b>Date and Time:&nbsp;<asp:Label ID="Label31" runat="server" Text='<%#Eval("visitDate") %>'/></b>&nbsp;&nbsp;
<asp:LinkButton ID="LnkBtn" runat="server" Text="Edit" OnClientClick='<%# Eval("ID", "window.open(\"EditReport.aspx?RID={0}\", null, \"width=810,height=630,top=100,left=10\", \"true\");") %>' />
</td>
</tr>

<tr >
<td colspan="2">
<table  cellpadding="0" cellspacing="0" border="0" class="border_table" Width="100%">
<tr>
<td colspan="2" style="padding-left:5px;padding-right:5px;">
<br />
  <div style="min-height:70px;background-color:White;" ><asp:Label ID="lbl1stReportValue" runat="server" TextMode="MultiLine"  Text='<%#Eval("visitRemarks") %>' Width="815px"  /></div>
</td>
</tr>
                                                 
</table>
</td>
</tr>

</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

Tuesday, April 15, 2014

Adding XML values in SQL azure using stored procedure

alter   Procedure spcInventory            
(            
@InventoryXML text,      
@WarrantID VARCHAR(50),    
@Result INT OUTPUT ,
@Addressid varchar(50)            
)            
as            
begin
  SET NOCOUNT ON        
  SET ANSI_NULLS ON        
  SET ANSI_PADDING ON        
  SET ANSI_WARNINGS ON        
  SET ARITHABORT ON        
  SET CONCAT_NULL_YIELDS_NULL ON        
  SET QUOTED_IDENTIFIER ON        
  SET NUMERIC_ROUNDABORT OFF
 
  DECLARE @xml xml
   
  set @xml=cast(@InventoryXML as xml)  
       
begin transaction Inventory
                   
declare @tempInventory        table(              
          Quantity VARCHAR(100),      
          Description VARCHAR(200),    
          MakeModel VARCHAR(200),    
          Valuation VARCHAR(100)    
          )              
       
               
  insert into @tempInventory(Quantity, Description,MakeModel,Valuation)              
                 
  SELECT T.c.value('./Quantity[1]','varchar(100)'),
  T.c.value('./Description[1]','varchar(200)'),
   T.c.value('./MakeModel[1]','varchar(200)'),
    T.c.value('./Valuation[1]','VARCHAR(100)')
 
   
  FROM @xml.nodes ('/Details/Inventory')  T(c)          
   
       
             
DELETE FROM Report_Inventry WHERE     upper(WarrantID) = upper(@WarrantID)   and Addressid=@Addressid
     
INSERT INTO Report_Inventry (Addressid,WarrantID,Quantity,Description_goods,MakeModel,Valuation)    
SELECT @Addressid, upper(@WarrantID), Quantity, Description,MakeModel,Valuation  FROM @tempInventory    
               
  if @@Error<>0              
  begin                
   set @Result = 0 --Error                  
   rollback transaction Inventory            
   return              
  end              
             
set @Result = 1 --Success                  
Commit transaction Inventory            
End  

Thursday, December 26, 2013

Login Autherntication using LDAP in asp.net

protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            string path = ConfigurationSettings.AppSettings["ldap"].ToString();
            DirectoryEntry objEntry = new DirectoryEntry(path, txtUserName.Text.Trim(), txtPassword.Text.Trim());
            DirectorySearcher search = new DirectorySearcher(objEntry);
            search.Filter = "(&(objectCategory=person)(SAMAccountName=" + txtUserName.Text.Trim() + "))";
            //search.Filter = "(&(objectCategory=person)(SAMAccountName=AjayK))";
            SearchResult result = search.FindOne();
            if (result != null)
            {
                DirectoryEntry de = result.GetDirectoryEntry();
                PropertyValueCollection groups = de.Properties["memberOf"];

                foreach (string s in groups)
                {
                    //Response.Write(s + "<br/>");
                    if (s.Contains("Managers ABC"))
                        Session["isMgr"] = true;
                }
                Session["name"] = txtUserName.Text.Trim();
                //Session["name"] = "rupeshm";
                Response.Redirect("Index.aspx");
            }
        }
        catch (DirectoryServicesCOMException)
        {
            {
               
              lblMsg.Text = "Invalid User Name or Password!!";
           
            }
        }
    }

Friday, December 20, 2013

How to add double quotes in URL in c#

I have URL

http://abc.io/v3/companies?filters={"info":"ddil"}&api_key=tk5qgu

and i Changes and handle double quotes like below

var url = "http://abc.io/v3/companies?filters={\"info\":\"ddil\"}&api_key=tk5qgu";


Thursday, December 12, 2013