Posts

Showing posts from 2024

REACT - MUI - Autocomplete - HelperText and Error

Image
                         REACT - MUI - Autocomplete - HelperText and Error   As normal MUI Control HelperText and Error props are not available inside the AutoComplete Control. To achieve the same We have use TextField props <Autocomplete              id="cboCountry"             options={CountryList}             getOptionLabel={(option) => option.countryName}             getOptionValue={(option) => option.id} /             value={CountrySelected}                size="small"                        sx={{ width: 300 }}             renderInput={(params) => (               <TextField ...

REACT- MUI - Dialog Box - Sample for confirmation of Delete Record. - Send Response value from Child Component to Parent

Image
REACT- MUI - Dialog Box - Sample for confirmation of Delete Record.  Sample code also  demonstrate how to send value from child component to parent component  // This method will be triggered on response from dialog box const ConfirmBoxHandleResponse = (ResponseValue) => {     if (ResponseValue === true) {       DeleteData();     }   };   // State variable to handle visibility of Dialog box   const [ShowConfirmationValue, SetShowConfirmationValue] =  useState(false); const ShowConfirmation = () => {      SetShowConfirmationValue(true);   };   // Button to trigger dialog box – for delete   <Button                 variant="outlined"                 startIcon={<DeleteIcon />}  ...

REACT-SELECT - Set Value from WEB-API and Update on selection.

Image
          REACT-SELECT - Set Value from WEB-API and Update on selection. import Select from "react-select"; let [CountryList, SetCountryList] = useState([]); // This will store the current selected value : same is required to assign the value to react-select on runtime selection. If same is not done selected value will not get updated  // Properties [id and countryName] name and case has to match with the data field which is  // comming from JSON. [GetCountryList] let [CountrySelected ,setCountrySelected] = useState({id:0, countryName:""}); let [StateMasterData, SetStateMasterData] = useState({     id: 0,     stateName: "",     countryID: 0,     countryName:"",   });  //Fetch API   useEffect(() => {     GetCountryList();     if (location.state.ID !== 0) {       GetData(location.state.ID);     }   }, [location.state.ID]); // Get Data from web -API...

REACT - ARROW FUNCTION

  Arrow Function Syntax for using Arrow Function // Normal Function function Add(a,b) {    return a +b } / /Arrow Function let AddWithAF = (a,b) =>{     return a +b } OR let AddWithAFInLine = (a,b) => a + b // Normal Function function IsPositive (number) { return number >= 0 } //Arrow Function let isPositiveWithAF (number) => return number >= 0 OR let isPositiveWithAFInLine number => return number >= 0 // Normal Function function GenerateRandomNumber () { return math.random } //Arrow Function GenerateRandomNumberWithArrowFunc () =>  return math.random

REACT - Sending Props to component

Sending Props to component in below sample we are sending Object as Props to child component it also has sample code for destructing of variable  // PARENT import React from "react" import ObjectASPropsInFunc from './ObjectAsPropsInFunc' function ObjectAsPropsMain() {     const persons    =[         {Name:"Switin", Email:"sk@test.co.in",              Contact :[{Phone:1234},{Phone:654},{Phone:987987}]         },         {Name:"Sam", Email:"sam@test.in",              Contact : [{Phone:546546},{Phone:6498797},{Phone:798797}]         }     ]     return(         <div>             <h3>This is Object to Component</h3>             <p>                 for working...

REACT - Controlled component and uncontrolled component

Controlled component and uncontrolled component Controlled Component : when an input control is managed by state is called Controlled component uncontroller component : when an input control is direct managed by java script or jquery i.e reading value of control using getelementbyid. // Controlled Component SAMPLE import React,{useState} from "react"; function ControlledComponentUsage() {         let [StateForInput,setStateForInput]  = useState('');         return(             <div>                 <input type="text" onChange={(e) => setStateForInput(e.target.value)} ></input>                 <p>                     value in Input Box : - {StateForInput}                 </p>           ...

SQL SERVER Try Convert

Image
SQL SERVER Try Convert Select TRY_CONVERT(int,123456) , TRY_CONVERT(int,'Char to NUmber')  , TRY_CONVERT(int,'00000111')  , TRY_CONVERT(int,'1234ACEF')   Instead of throwing error it will return Null Select TRY_CONVERT(Date,'12/24/2015'),  TRY_CONVERT(Date,'12242015')  Instead of throwing error it will return Null

SQL Server Concat Feature

Image
SQL Server  Concat  Feature Concat  - feature allow to merge two string values. If value which are getting concat has null inside the same. All other content of that part will not get concat into string.  This Good Feature when it come to  Concatation of String Value Specify Address When certain Part of value is not there it still shows Comma Select Concat('Switin ' ,  ',' +  'G'  +   ','  , ' Kotian'), Concat('Switin ' ,  ', ' +  NULL  +   ', '  , 'Kotian')      In Case of NULL The Comma is not appearing. 

SQL SERVER - Alter with Default Values

SQL SERVER  -  Alter with Default Values -- Alter Table to add Field with Default Value for Existing Records -- Which is not possible with Multiple Alter add Statement for Column and Constrainst Alter TABLE [dbo].[Table_1] ADD [UUUX] [bit] NOT NULL  CONSTRAINT [DF_Table_1_UUUX]  DEFAULT 0   Alter TABLE [dbo].[Table_1] ADD [YUYUY1234] [int] NOT NULL  CONSTRAINT  [YUYUY1234] DEFAULT ((0) )   

SQL SERVER - Check for Carriage Return or Enter and Replace with Space

SQL SERVER  -   Check for Carriage Return or Enter Select  Charindex(CHAR(13)+char(10),Address,1) , REPLACE(Address,CHAR(13)+char(10),'') from mastShipToParty

SQL Server - Generate a script for fields which are part of each table in database

  SQL Server - Generate a script for fields which are part of each table in database When you need to some fixed fields to be part of each header table in database and always we have to create those field manually by type field name and creating foreign key. We can do this with help of below script. which I found helpful each time in create new table in database. In my case I had AddOprID , and EditOprID to part of each table and same is foreign key reference to User Master.   Declare @UserTable as Varchar(100) Declare @Schema as Varchar(100) Declare @Table as Varchar(100) Declare @SQL as varchar(8000)     SET @UserTable ='mastUser' SET @Schema ='dbo' SET @Table ='TranSales'     SET @SQL   = 'Alter TABLE [' + @Schema +'].[' + @Table + '] ADD [AddOprID] [int] NOT NULL   ' + Convert(Varchar,CHAR(10)) +                         ...

SQL SERVER - BEGIN TRANSCATION AND ROLLBACK

            SQL SERVER - BEGIN TRANSCATION AND ROLLBACK  USE [tempdb] GO /****** Object:  Table [dbo].[Table_1]    Script Date: 02/06/16 18:05:30 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Table_1]( [fld1] [int] NULL, [fld2] [int] NULL ) ON [PRIMARY] GO Insert into Table_1 (fld1,fld2) Values (0,100) begin Select * from Table_1 End  -- This will Terminat T-sql and rollback same if error occurs begin Try begin tran Delete from Table_1 Where fld1 = 0 Insert into Table_1 (fld1,fld2) Values ('Switin',0) COMMIT Tran End Try begin Catch SELECT ERROR_MESSAGE() AS ErrorMessage;   ROLLBACK TRAN  End Catch -- Begin End will not stop execution of next T-sql . Its Just logic Grouping of T-SQL begin Delete from Table_1 Where fld1 = 0 Insert into Table_1 (fld1,fld2) Values ('Switin',0) Select * from Table_1 End 

Syncfusion Multicolumn Combobox - adding Data in Design Time in Combobox

Image
Syncfusion Multicolumn Combobox - adding Data in Design Time in Combobox Have data in multicolumn combo box in Design Time. Custom Data Item Window to add data in combo box   Custom property which will help to add data in combobox       Step 1 – Create Inherited Custom Control using Syncfusion Multicolumn Combo box         Step 2 – Custom Class to hold Data item Public Class ComboItem     Dim strText As String     Dim strValue As String       Public Property Text() As String         Get             Return strText         End Get         Set(ByVal value As String)             strText = value         End Set     End Property     ...

Syncfusion GridControl - Create extended Custom Column Properties

Image
Syncfusion GridControl - Create extended Custom Column Properties  When you need some additional information stored. Which can used in the runtime for saving or validating. you will need to have  extended column properties. With we can some additional properties in GridControl which can be accessed in code. Such as is the column required,  Custom Error Message , DataType, Fieldname in database which will be linked to column and so on.  created a property which take information as per column index     Syncfusion GridControl is inherited and custom grid is created namespace ATS.WinForms.Controls {     public partial class Grid : GridControl     { [Description("Set Grid Column Properties"), Category("ATS")] [EditorAttribute(typeof(System.ComponentModel.Design.ArrayEditor), typeof(System.Drawing.Design.UITypeEditor))] public GridColumnProperties[] ColumnProperties {      get      { ...

Syncfusion - GridControl - FormulaCell - Formatting with Decimal

Syncfusion - GridControl - FormulaCell For Formatting FormulaCell with leading Zero when it .999 TO 0.999 grdReport.Item(CurrentRow, intCol).Format = "##,###0.000"c

Syncfusion - GridControl - Range selection for property to be applied

Syncfusion - GridControl Range selection for property to be applied  ' Create a GridStyleInfo object Dim style As GridStyleInfo = New GridStyleInfo ' Set some properties style.BackColor = Color.SkyBlue style.TextColor = Color.RosyBrown style.CellType = "TextBox" style.Text = "EssentialGrid" ' Create a GridRangeInfo object Dim range As GridRangeInfo = GridRangeInfo.Cells(1, 1, 5, 5) ' Apply the style to the range Me.GridControl1.ChangeCells(range, style, Syncfusion.Styles.StyleModifyType.Override)

Syncfusion GridControl Textbox - Restrict from pasting of the character more than maxlength

Syncfusion GridControl  Textbox Celltype Restrict from pasting of the character more than maxlength  Private Sub GridControl1_CurrentCellValidateString(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridCurrentCellValidateStringEventArgs) Handles GridControl1.CurrentCellValidateString         If (e.Text.Length > GridControl1.ColStyles(1).MaxLength) Then             e.Cancel = True         End If  End Sub Private Sub GridControl1_PasteCellText(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPasteCellTextEventArgs) Handles GridControl1.PasteCellText         If (e.Text.Length > e.Style.MaxLength) Then             e.Cancel = True             e.Abort = False         End If     End Sub

SQL SERVER - Sequence Type in SQL With table

Sequence Type in SQL With table  SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[Table_1]( [ID] [int] IDENTITY(1,1) NOT NULL, [ContinousNumber] [bigint] NULL, [name] [varchar](50) NULL,  CONSTRAINT [PK_Table_1] PRIMARY KEY CLUSTERED  ( [ID] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO CREATE SEQUENCE [dbo].[Sequence-20191206-124448]   AS [bigint]  START WITH 1  INCREMENT BY 1  MINVALUE -9223372036854775808  MAXVALUE 9223372036854775807  NO CACHE  GO Delete from [Table_1] --- Check working of Sequence INSERT INTO [dbo].[Table_1] ([ContinousNumber],[name]) VALUES ( NEXT VALUE FOR [Sequence-20191206-124448],'AABC') SELECT TOP (1000) [ID]       ,[ContinousNumber]       ,[name]   FROM [ACFAFEC02122019].[dbo].[Table_1] --- Reset the Sequence ALTER SEQUENCE [Sequence-...

SQL Server - Using Declare in Table value Function

Sql Server - Using Declare in Table value Function create function Func() returns @T table(ColName int) as begin           declare @Var int           set @Var = 10           insert into @T(ColName) values (@Var)           return end

Sql Server - Find Missing Number in Sequence

Sql Server - Find Missing Number in Sequence Select * from  ( SELECT Min([GPNo]) AS StartPos , Max(GPNO) as EndPos FROM [tempdb].[dbo].[Table_1] ) SRC Outer apply ( Select Top(EndPOs) Row_Number() Over (Order by Name) as RNO from Sys.columns ) X Left outer join Table_1  on Table_1.GpNo = RNO Where GPNO Is NULL

SQL SERVER - Alternative to Like Condition

SQL SERVER - Alternative to Like Condition DECLARE @Acc TABLE ( ID  int, AccountName Varchar(200) ) Insert into @Acc (ID,AccountName)  Values (1,'Switin Kotian'),(2,'Jitesh Shiyal'),(3,'Ramesh Bangera'),(4,'Shrikant Chavan'),(5,'Dipti Patil'),(6,'Bhan Asher'),(7,'Smruti Kotian') Select * From @Acc Select * From @Acc Where AccountName Like 'S%' Select * From @Acc Where CharIndex('S',AccountName) = 1 Select * From @Acc Where Left(AccountName,1) = 'S' Select * From @Acc Where SUBSTRING(AccountName,1,1) = 'S'

Sql Server - How to have Multiple IF Condition in Table Valued Functions

  How to have Multiple IF Condition in Table Valued Functions   CREATE FUNCTION  dbo.testTVF (                 @Parameter1  as varchar(2) ,                 @Parameter2 as integer ) RETURNS @mytable table (                              CountOfRecords int ) As   begin                   if (@Parameter1  ='LP' )                                 Insert into @mytable (CountOfRecords)           ...