Translate

Monday, 27 May 2024

TASK 1A 2B 3C 4D 5E

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            List<string> numbers = new List<string> { "1", "2", "3", "4", "5" };

            List<string> chars = new List<string> { "A", "B", "C", "D", "E" };   


            for (int indexNumber = 0; indexNumber < numbers.Count; indexNumber++)

            {

                for (int indexChar = 0; indexChar < chars.Count; indexChar++)

                {

                    if (indexNumber == indexChar)

                    {

                        Console.WriteLine(numbers[indexNumber] + chars[indexChar]);

                    }

                }

            }

            Console.ReadLine();// OutPut 1A 2B 3C 4D 5E

        }

    }

}

Saturday, 11 November 2023

SQL server Capitalize First Letter

 ---Input String 'PABITRA MICROSOFT PabiTra miCroSoft'

declare @SQLColumnName nvarchar(max)

set @SQLColumnName = 'PABITRA MICROSOFT PabiTra miCroSoft'

declare @SpaceInWord char(1) = ' '

-- Upper case first letter and all others in lower case letters

select @SQLColumnName = STUFF(LOWER(@SQLColumnName), 1, 1, UPPER(LEFT(@SQLColumnName,1)) )

-- search for space character

declare @i int = CHARINDEX(@SpaceInWord, @SQLColumnName, 1)

while @i > 0

begin

 select @i = @i + 1

 -- replace character after space with its upper case letter

 select @SQLColumnName = STUFF(@SQLColumnName, @i, 1, UPPER( SUBSTRING(@SQLColumnName, @i, 1)) )

 -- search for next space character

 select @i = CHARINDEX(@SpaceInWord, @SQLColumnName, @i)

end

select @SQLColumnName

---Out Put : 'Pabitra Microsoft Pabitra Microsoft'






using cursor

----------

 

 

 declare @PrinterId int,@SQLColumnName varchar(1000)

declare _cursor cursor read_only for

select PrinterId,PAddress from PrinterDetails

open _cursor

fetch next from _cursor into @PrinterId,@SQLColumnName

while @@FETCH_STATUS=0

begin

-----------------------------Body

declare @SpaceInWord char(1) = ' '


-- Upper case first letter and all others in lower case letters

select @SQLColumnName = STUFF(LOWER(@SQLColumnName), 1, 1, UPPER(LEFT(@SQLColumnName,1)) )


-- search for space character

declare @i int = CHARINDEX(@SpaceInWord, @SQLColumnName, 1)


while @i > 0

begin

 select @i = @i + 1

 -- replace character after space with its upper case letter

 select @SQLColumnName = STUFF(@SQLColumnName, @i, 1, UPPER( SUBSTRING(@SQLColumnName, @i, 1)) )

 -- search for next space character

 select @i = CHARINDEX(@SpaceInWord, @SQLColumnName, @i)

end


--select @SQLColumnName

update PrinterDetails set PAddress=@SQLColumnName where PrinterId=@PrinterId

 -----------------------------Body end 

fetch next from _cursor into  @PrinterId,@SQLColumnName

end

close _cursor

deallocate _cursor



SQL queries to change the column datatype type

 Column with data type : AadhaarNumner int 

SQL queries to change the column datatype type

Alter table dbo.OrderPaperBooks alter column AadhaarNumner varchar(20)

SQL query for alter column name

 table name: dbo.OrderPaperBooks

old column name : PPNoOfCopy

assign new column name :NoOfCopy 


SQL query for alter column name 


 EXEC sp_rename 'dbo.OrderPaperBooks.PPNoOfCopy', 'NoOfCopy', 'COLUMN';

Friday, 3 November 2023

drop and create SQL Server procedure simple way

 IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'USP_BookTypes')

DROP PROCEDURE USP_BookTypes

GO

CREATE  PROC USP_BookTypes

(

   @action varchar(20)

  ,@BookTypeId int=null

  ,@BookType varchar(100)=null

)

AS BEGIN

  IF(@action='SELECTALL')

   BEGIN

    SELECT B.BookTypeId,B.BookType FROM BookTypes B WITH(NOLOCK)  

WHERE B.IsActive='Y'  order by B.BookTypeId; 

   END

   ELSE IF(@action='SELECTBYID')

   BEGIN

    SELECT B.BookTypeId,B.BookType FROM BookTypes B WITH(NOLOCK)  

WHERE B.BookTypeId=@BookTypeId and B.IsActive='Y' order by B.BookTypeId; 

   END

 END 

Thursday, 26 October 2023

singleton design pattern c#

 


 Calling the Singleton Design Pattern c# Class



namespace OrderProcessing.BusinessLayer

{

    public class BLLClass

    {

        public BLLClass()

        {

            //

            // TODO: Add constructor logic here

            //

        }

        public string bllAddClass(ClassModelAddUpdateRequst Requst)

        {


            string response = "error";

            response = Helper.Instance.ExecuteScalar(

                                        commandText: "USP_CLASS"

                                       , commandType: CommandType.StoredProcedure

                                       , sqlParameters:

                                        new SqlParameter[]{

                                                          new SqlParameter("@action", SqlDbType.Char, 20) { Value =Requst.action }

                                                         ,new SqlParameter("@ClassNameNumber", SqlDbType.Int) { Value =Requst.ClassNameNumber }

                                                         ,new SqlParameter("@ClassNameText", SqlDbType.VarChar, 20) { Value = Requst.ClassNameText }

                                                         ,new SqlParameter("@ClassNameRoman", SqlDbType.NVarChar, 20) { Value = Requst.ClassNameRoman }

                                                         ,new SqlParameter("@ClassNameOdia", SqlDbType.NVarChar, 20) { Value = Requst.ClassNameOdia }

                                                         ,new SqlParameter("@EntryBy", SqlDbType.VarChar, 20) { Value = Requst.userId }

                                                          }

                                   );


            return response;


        }

}


Singleton Design Pattern c# Class



public sealed class Helper

    {


        private Helper() { }

        private static Helper instance = null;

        public static Helper Instance

        {

            get

            {

                if (instance == null)

                {

                    instance = new Helper();

                }

                return instance;

            }

        }

        private string objCon;

        private SqlConnection Conn;

        public SqlConnection Connect()

        {

            objCon = ConfigurationManager.ConnectionStrings["sqlServerConn"].ConnectionString;

            Conn = new SqlConnection(objCon);

            if (Conn.State == ConnectionState.Open)

                Conn.Close();

            Conn.Open();

            return Conn;

        }

        public int ExecuteNonQuery(string commandText, CommandType commandType, SqlParameter[] sqlParameters)

        {

            int x = 0;

            try

            {

                Conn = Connect();

                SqlCommand cmd = new SqlCommand(commandText, Conn);

                cmd.CommandType = commandType;

                cmd.CommandTimeout = 0;

                if (sqlParameters != null && sqlParameters.Length != 0)

                {

                    cmd.Parameters.AddRange(sqlParameters);

                }

                x = cmd.ExecuteNonQuery();

                Conn.Close();

                Conn.Dispose();

                cmd.Dispose();

            }

            catch (Exception ex)

            { throw ex; }

            return x;

        }

}

Monday, 24 July 2023

Contact Form

 <!DOCTYPE html>

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Contact Form</title>
  <link href="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
</head>
<body class="well well-sm">
<div class="container">
  <div class="row">
      <div class="col-md-12 col-md-offset-0.5">
       
          <form class="form-horizontal">

            <div class="col-md-12">
              <div class="col-md-4"></div>
            <div class="col-md-4">
            <h1>Contact Us</h1>
           
            </div>
            <div class="col-md-4"></div>
          </div>
          <hr>
            <!-- Name input-->
            <div class="form-group">
              <label class="col-md-3 control-label" for="name">Name</label>
              <div class="col-md-9">
                <input id="txtName" name="name" tabindex="1" type="text" maxlength="100" title="Enter Your Name" placeholder="Your name" class="form-control">
              </div>
            </div>
            <!-- City input-->
            <div class="form-group">
              <label class="col-md-3 control-label" for="name">City</label>
              <div class="col-md-9">
                <input id="txtCity" name="city" tabindex="2"  type="text" maxlength="100"  title="Enter Your City"  placeholder="Your city" class="form-control">
              </div>
            </div>
            <!-- Email input-->
            <div class="form-group">
              <label class="col-md-3 control-label" for="email">Your E-mail</label>
              <div class="col-md-9">
                <input id="txtEmail" name="email"  tabindex="3"  type="text" maxlength="100"  title="Enter Your E-mail"  placeholder="Your email" class="form-control">
              </div>
            </div>
          <!-- DOB input-->
            <div class="form-group">
              <label class="col-md-3 control-label" for="email">Your Date Of Birth</label>
              <div class="col-md-9">
                <input id="txtDOB" name="dob"  tabindex="4"  type="date"  maxlength="10" title="Enter Your Date Of Birth" placeholder="Your Date Of Birth" class="form-control">
              </div>
            </div>
             <!-- Contact number input-->
            <div class="form-group">
              <label class="col-md-3 control-label" for="email">Your Contact number</label>
              <div class="col-md-9">
                <input id="txtContactNumber" name="contactnumber" title="Enter Your Contact number"  tabindex="5"  type="number"  maxlength="10"  placeholder="Your Contact number" class="form-control">
              </div>
            </div>
            <!-- Message body -->
            <div class="form-group">
              <label class="col-md-3 control-label" for="message">Your message</label>
              <div class="col-md-9">
                <textarea class="form-control" id="txtMessage" title="Enter Your message"  maxlength="150"   tabindex="6"  name="message" placeholder="Please enter your message here..." rows="5"></textarea>
              </div>
            </div>
   
            <!-- Form actions -->
            <div class="form-group">
              <div class="col-md-12 text-right">
                <button type="submit" class="btn btn-primary btn-lg"  title="Click here to submit the form "  tabindex="7" id="btnSubmit" >Submit</button>
              </div>
            </div>
          </form>
        </div>
      </div>
 
</div>
  <script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
  <script type="text/javascript">
  $(document).ready(function() {
   
      $('#btnSubmit').click(function () {
          if (validateForm()) {

              if (SubmitData()) {
                  alert('Data save succssfully !!!');
              }


          } else {
              return false;
          }
      });
     

  });



  function SubmitData() {
      alert('Server side code call ');
      var saveStatus = false;
      if (saveStatus)
          return true;
      else
      return false;
  }
  function validateForm()
  {
     
      var status =false;
      if ($('#txtName').val() == '')
      {
          $('#txtName').focus();
          alert('Name Field can not be blank');
      }else if($('#txtName').val().length>100)
      {
          $('#txtName').focus();
          alert('Name Field must not grater than 100');
      }
      else if ($('#txtCity').val() == '') {
          $('#txtCity').focus();
          alert('City Field can not be blank');
      } else if ($('#txtCity').val().length > 100) {
          $('#txtCity').focus();
          alert('City Field must not grater than 100');
      }
      else if ($('#txtEmail').val() == '') {
          $('#txtEmail').focus();
          alert('Email Field can not be blank');
      } else if ($('#txtEmail').val().length > 100) {
          $('#txtEmail').focus();
          alert('Email Field must not grater than 100');
      }
      else if ($('#txtDOB').val() == '') {
          $('#txtDOB').focus();
          alert('DOB Field can not be blank');
      } else if ($('#txtDOB').val().length > 10) {
          $('#txtDOB').focus();
          alert('DOB Field must not grater than 10');
      }
      else if ($('#txtContactNumber').val() == '') {
          $('#txtContactNumber').focus();
          alert('Contact number Field can not be blank');
      } else if ($('#txtContactNumber').val().length > 10) {
          $('#txtContactNumber').focus();
          alert('Enter 10 digit contact number ');
      } else if ($('#txtMessage').val() == '') {
          $('#txtMessage').focus();
          alert('message Field can not be blank');
      } else if ($('#txtMessage').val().length > 150) {
          $('#txtMessage').focus();
          alert('DOB Field must not grater than 150');
      }else {
          status = true;
      }
      return status;
  }

    </script>
 
 
</body>
</html>

Friday, 7 July 2023

DataTable to json serializer

 void loadData()

{

DataTable dtRes=new DataTable();

dtRes=Dll.GetEmployee();

 stringJsonData=toJson(dtRes);

}


public string toJson(DataTable dt)

    {

        System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();

        List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();

        Dictionary<string, object> row;

        foreach (DataRow dr in dt.Rows)

        {

            row = new Dictionary<string, object>();

            foreach (DataColumn col in dt.Columns)

            {

                row.Add(col.ColumnName, dr[col]);

            }

            rows.Add(row);

        }

        return serializer.Serialize(rows);

    }

Friday, 16 June 2023

List of JavaScript Engines compiler runtime

 List of JavaScript Engines compiler runtime

BrowserName of Javascript Engine
Google ChromeV8
Edge (Internet Explorer)Chakra
Mozilla FirefoxSpider Monkey
Safari Javascript Core Webkit

Wednesday, 26 January 2022

Jquery modal popup on page load

 

<html lang="en">
<head>
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <title>Document</title>
 </head>
 <body>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="container">
    <!-- Modal -->
    <div class="modal fade" id="myModal" role="dialog">
        <div class="modal-dialog">

            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Modal Header</h4>
                </div>
                <div class="modal-body">
                    <p>Some text in the modal.</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>

</div>
<script>
$( document ).ready(function() {
    let todaysDate = new Date();
    // let dateOfClosing = new Date('02 03 2022'); // 03 Feb 2022  
    let dateOfClosing = new Date('01 25 2022'); // new Date('mm dd yyyy')
   
     alert('Date Of Closing:'+dateOfClosing);
     alert('Todays Date:'+todaysDate);

        if(todaysDate<=dateOfClosing)
        {
        $('#myModal').modal('show');
        }
});
</script>
</body>
</html>

Friday, 21 January 2022

sql query for count number of parameters in user stored procedures

 SELECT 

    p.name AS Parameter,        

    t.name AS [Type]

FROM sys.procedures sp

JOIN sys.parameters p 

    ON sp.object_id = p.object_id

JOIN sys.types t

    ON p.system_type_id = t.system_type_id

WHERE sp.name = 'usp_get_customer' order by p.name

Monday, 17 January 2022

table format - candidate registration form

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Candidate Registration Form</title>

</head>

<body>

<h2>Candidate Registration Form</h2>

<form id="register" method="post">

<table>

                        <tr> 

                            <td colspan="6" style="text-align: right;margin-right:5px;color:red;font-size: 15pt;"><b>* fields are mandatory </b></td>                            

                        </tr>  

                        <tr> 

                            <td colspan="6"></td>                            

                        </tr>  

                        <tr> 

                            <td colspan="6"></td>                            

                        </tr>  

                        <tr>                            

                            <td>

                                <b>1. <span style="color:red;">*</span>First Name</b>

                            </td>

                            <td>

                                <input type="text" name="firstName" tabindex="1" max="30" title="Enter candidate first name" id="txtFirstName" placeholder="First Name" required> 

                            </td>                      

                        <td>

                            <b>2. Middle Name</b>

                        </td>

                        <td>

                            <input type="text" name="middleName" tabindex="2" max="30" title="Enter candidate middle name" id="txtMiddleName" placeholder="Middle Name"> 

                        </td>

                        <td>

                            <b>3. <span style="color:red;">*</span>Last Name</b>

                        </td>

                        <td>

                            <input type="text" name="lastName" tabindex="2" max="30" title="Enter candidate Last Name" id="txtLastName" placeholder="Last Name" required>  

                        </td>                             

                    </tr> 

                    <tr>                            

                        <td>

                            <b>4. <span style="color:red;">*</span>Father Name</b>

                        </td>

                        <td>

                            <input type="text" name="fatherName" tabindex="4" max="100" title="Enter candidate father name" id="txtFatherName" placeholder="Father Name" required> 

                        </td>                      

                    <td>

                        <b>5. <span style="color:red;">*</span>Mother Name</b>

                    </td>

                    <td>

                        <input type="text" name="motherName" tabindex="5" max="100" title="Enter candidate Mother Name" id="txtMotherName" placeholder="Mother Name"> 

                    </td>

                    <td>

                        <b>6. Gurdian Name</b>

                    </td>

                    <td>

                        <input type="text" name="gurdianName" tabindex="6" max="100" title="Enter candidate gurdian name" id="txtGurdianName" placeholder="Gurdian Name">  

                    </td>                         

                </tr> 

                <tr>                            

                    <td>

                        <b>7. <span style="color:red;">*</span>Date of birth</b>

                    </td>

                    <td>

                        <input type="date" name="dateOfBirth" tabindex="7" max="10" title="Enter candidate date of birth" id="txtDateOfBirth" placeholder="Date of birth" required> 

                    </td>                      

                <td>

                    <b>8. <span style="color:red;">*</span>Gender</b>

                </td>

                <td>

                    <input type="radio" name="male" tabindex="8"  title="Male">Male

                    &nbsp;

                    <input type="radio" name="female" tabindex="9"  title="Female">Female 

                    &nbsp;

                    <input type="radio" name="others" tabindex="10"  title="Others">Others

                    &nbsp;

                </td>

                <td>

                    <b>9. <span style="color:red;">*</span>Mobile Number</b>

                </td>

                <td>

                    <input type="number" name="gurdianName" tabindex="11" max="10" title="Enter candidate mobile number" id="txtMobileNumber" placeholder="Mobile Number">  

                </td>                     

            </tr>

            <tr>                            

                <td>

                    <b>10. Whatsapp Number</b>

                </td>

                <td>

                    <input type="number" name="gurdianName" tabindex="12" max="10" title="Enter candidate whatsapp number" id="txtWhatsappNumber" placeholder="Mobile Number">  

                </td>                   

                <td>

                    <b>11. Email</b>

                </td>

                <td>

                    <input type="text" name="email" tabindex="13" max="256" title="Enter candidate Email" id="txtEmail" placeholder="Email">  

                </td>

                <td>

                    <b>12. Address</b>

                </td>

                <td>

                    <textarea name="address" tabindex="14" max="256" title="Enter candidate Address" id="txtAddress" placeholder="Address"> </textarea>

                </td>  

            </tr> 

            <tr>                            

                <td>

                    <b>13. <span style="color:red;">*</span>Pincode</b>

                </td>

                <td>

                    <input type="number" name="pincode" tabindex="15" max="6" title="Enter candidate Pincode" id="txtPincode" placeholder="Pincode">  

                </td>                   

                <td>

                    <b>14. <span style="color:red;">*</span>Matriculation mark</b>

                </td>

                <td>

                    <input type="number" name="matriculationMark" tabindex="16" max="5" title="Enter candidate Matriculation mark" id="txtMatriculationMark" placeholder="Matriculation mark">  

                </td>

                <td>

                    <b>15. <span style="color:red;">*</span>Intermediate mark</b>

                </td>

                <td>

                    <input type="number" name="intermediateMark" tabindex="17" max="5" title="Enter candidate Intermediate mark" id="txtIntermediateMark" placeholder="Intermediate mark">  

                </td> 

            </tr> 

            <tr>                            

                <td>

                    <b>16. Graduation mark</b>

                </td>

                <td>

                    <input type="number" name="graduationMark" tabindex="18" max="6" title="Enter candidate Graduation mark" id="txtGraduationMark" placeholder="Graduation mark">  

                </td>                   

                <td>

                    <b>17. Post graduation mark</b>

                </td>

                <td>

                    <input type="number" name="postGraduationMark" tabindex="19" max="5" title="Enter candidate Post graduation mark" id="txtPostGraduationMark" placeholder="Post graduation mark">  

                </td>

                <td>                    

                </td>

                <td>                    

                </td> 

            </tr> 

            <tr> 

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

            </tr>   

            <tr> 

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

            </tr>   

            <tr> 

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

                <td></td>

            </tr>   

            <tr>  

                <td>                    

                </td>      

                <td>                    

                </td>                                

                <td colspan="6">                

                    <input type="submit" id="btnSubmit" value="Submit" tabindex="20" title="Click here for completion of the candidate registration form" >

                    &nbsp;

                    <input type="button"  id="btnCancel"  value="Cancel" tabindex="21" title="Click here for cancel the  candidate registration form" >

                    &nbsp;

                    <input type="button" id="btnReset" value="Reset"  tabindex="22" title="Click here for Reset the  candidate registration form" >

                </td> 

            </tr> 

                    </table>

                </form>            

    </body>

</html>

 

Sunday, 16 January 2022

dynamically add column in sql temp table

 CREATE TABLE student 

(

student_id int

,student_name varchar(100)

,class int

)

insert into student(student_id,student_name,class) values(10001,'Pabitra Behera',10);

insert into student(student_id,student_name,class) values(10002,'Swasti Prakash Brahma',10);

insert into student(student_id,student_name,class) values(10003,'Ankit Kalia',10);

CREATE TABLE tsubject 

(

subject_id int

,subjects varchar(100)

 

)

insert into tsubject values(1, 'Odia');

insert into tsubject values(2, 'English');

insert into tsubject values(3, 'Hindi');

create proc USP_GET_DATA

(

@action varchar(10)=null

)

AS BEGIN

SELECT * INTO #tstudent FROM student with(nolock)

 

 declare @COLUMN_NAME varchar(256)

declare _cursor cursor read_only for

select subjects from tsubject

open _cursor

fetch next from _cursor into @COLUMN_NAME

while @@FETCH_STATUS=0

begin

declare @DynamicSQL nvarchar(max);

SET @DynamicSQL = 'ALTER TABLE #tstudent ADD ['+ CAST(@COLUMN_NAME AS NVARCHAR(100)) +'] NVARCHAR(100) NULL'

EXEC(@DynamicSQL) 

 

fetch next from _cursor into  @COLUMN_NAME

end

close _cursor

deallocate _cursor

select * from #tstudent

 

END

Saturday, 27 November 2021

table border all td and tr border



<table style='width:100%; border-collapse:collapse; font-size: 14px; background-color: #ffffff;  border-color:black;' border='1px' cellpadding='5' cellspacing='5'>

<tr>

<th>Id</th>

<th>Name</th>

<th>DOB</th>

<th>Mobile</th>

</tr>

<tr>

<td>1</td>

<td>Microsoft</td>

<td>4 April 1975</td>

<td>910998989</td> 

</tr>

<tr>

<td>2</td>

<td>IBM</td>

<td>4 April 1975</td>

<td>910998989</td> 

</tr>

<tr>

<td>3</td>

<td>Accenture</td>

<td>4 April 1975</td>

<td>910998989</td> 

</tr>

<tr>

<td>4</td>

<td>Pabitra Microsoft</td>

<td>4 April 1975</td>

<td>910998989</td> 

</tr>

</table>