sudo chmod -R 777 w3yelp
PostgreSQL Run on Docker with Create User and Database
1.
4.
5.
6.
docker pull postgres2
docker run --name postgresdb -v /home/sudipto/Development/PostgresDb:/var/lib/postgresql/data -p 5432:5432 -e POSTGRES_PASSWORD=root -d postgres3.
docker inspect postgresdb
4.
docker exec -it postgresdb bash
5.
psql -U postgres -W
6.
CREATE USER user11 SUPERUSER PASSWORD '69use420';7.
CREATE DATABASE pguser11db1;8.
GRANT ALL PRIVILEGES ON DATABASE pguser11db1 TO user11;
Copy a whole website via Linux command
wget --recursive --no-clobber --page-requisites --html-extension --convert-links --restrict-file-names=windows --domains devitems.com --no-parent devitems.com/html/intensy-preview/
------------------------Or------------------------------------
wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://themesground.com/Superb/
------------------------Or------------------------------------
wget --limit-rate=200k --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://themesground.com/Superb/
SingleTon Design Pattern Java
Create a Java Application Project.
Post this 2 class file in root.
-------------File MainClass.java-----------------------------------------------------------------------------
package singleton;
public class MainClass {
public static void main(String[] args) {
MathHelper tmp = MathHelper.getInstance(12);
MathHelper tmp2 = MathHelper.getInstance(14);
MathHelper tmp3 = MathHelper.getInstance(16);
tmp.demoMethod();
tmp2.demoMethod();
tmp3.demoMethod();
}
}
------------------------------------------------------------------------------------------
-------------File MathHelper.java-----------------------------------------------------------------------------
package singleton;
public class MathHelper {
private static int sNumber;
private static MathHelper singleton;
/* A private Constructor prevents any other * class from instantiating. */
private MathHelper() {
}
/* Static 'instance' method */
public static MathHelper getInstance(int number) {
if (singleton == null) {
sNumber = number;
singleton = new MathHelper();
}
return singleton;
}
/* Other methods protected by singleton-ness */
public static void demoMethod() {
System.out.println("DemoMethod for singleton: Number= " + sNumber);
}
}
------------------------------------------------------------------------------------------
Run MainClass.java file.
You got result
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
Same result for every time.
It's can update private static variable 'sNumber' only first time by method ‘getInstance()’. Because then no object create yet. Only first time object is null. Then it’s creating a new object by considering current object is null and return it. At that time 'sNumber' able to update its value to 12.
After creating first time object, it will never able to create new object and can't update the 'sNumber'. It's return the same old object every time. And we got 12 , even we push new value when we get new object.
Post this 2 class file in root.
-------------File MainClass.java-----------------------------------------------------------------------------
package singleton;
public class MainClass {
public static void main(String[] args) {
MathHelper tmp = MathHelper.getInstance(12);
MathHelper tmp2 = MathHelper.getInstance(14);
MathHelper tmp3 = MathHelper.getInstance(16);
tmp.demoMethod();
tmp2.demoMethod();
tmp3.demoMethod();
}
}
------------------------------------------------------------------------------------------
-------------File MathHelper.java-----------------------------------------------------------------------------
package singleton;
public class MathHelper {
private static int sNumber;
private static MathHelper singleton;
/* A private Constructor prevents any other * class from instantiating. */
private MathHelper() {
}
/* Static 'instance' method */
public static MathHelper getInstance(int number) {
if (singleton == null) {
sNumber = number;
singleton = new MathHelper();
}
return singleton;
}
/* Other methods protected by singleton-ness */
public static void demoMethod() {
System.out.println("DemoMethod for singleton: Number= " + sNumber);
}
}
------------------------------------------------------------------------------------------
Run MainClass.java file.
You got result
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
DemoMethod for singleton: Number= 12
Same result for every time.
It's can update private static variable 'sNumber' only first time by method ‘getInstance()’. Because then no object create yet. Only first time object is null. Then it’s creating a new object by considering current object is null and return it. At that time 'sNumber' able to update its value to 12.
After creating first time object, it will never able to create new object and can't update the 'sNumber'. It's return the same old object every time. And we got 12 , even we push new value when we get new object.
Ubuntu Create Launcher
create a file name with [android-studio.desktop]
[-----------------------------------------------------------------------------------------------------------------------]
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec=/home/w3e/Programs/android-studio/bin/studio.sh
Icon=/home/w3e/Programs/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
Name[en_GB]=android-studio.desktop
[-----------------------------------------------------------------------------------------------------------------------]
Dont forget to make the file executable (
[-----------------------------------------------------------------------------------------------------------------------]
[Desktop Entry]
Version=1.0
Type=Application
Name=Android Studio
Exec=/home/w3e/Programs/android-studio/bin/studio.sh
Icon=/home/w3e/Programs/android-studio/bin/studio.png
Categories=Development;IDE;
Terminal=false
StartupNotify=true
StartupWMClass=jetbrains-android-studio
Name[en_GB]=android-studio.desktop
[-----------------------------------------------------------------------------------------------------------------------]
Dont forget to make the file executable (
chmod +x android-studio.desktop
).Complexity Reducing of Java Code
public boolean isAllowedFileExtension(String extension) { boolean isSupported = false; try { ///Instead of this code block, use following block
if (extension.contains("pdf") || extension.contains("doc") || extension.contains("docx") || extension.contains("ppt") || extension.contains("pptx") || extension.contains("apk") || extension.contains("zip") || extension.contains("rar"))
{ isSupported = true; } ///Use this code block, instead of above code block
String[] fieldsToInclude = {"pdf", "doc", "docx","ppt"};
for (int i = 0; i < fieldsToInclude.length; i++) { if (extension.contains(fieldsToInclude[i])) isSupported = true; break; } } catch (Exception e) { Log.e("isAllowedFile", e.toString()); } return isSupported; }
Optional Parameters Sequence Interchange
///Calling Class
public class Student
{
public void PrintList()
{
var wg = new WebGrid();
wg.Print(new List<Student>(), 1, 100, "Name", "ASC");
}
}
///Called Class
public class WebGrid
{
//Main Method
internal void Print(List<Student> list, int page, int size, string sortBy, string sortDirection)
{
//No Error
throw new NotImplementedException();
}
//You Want
internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection)
{
//Error , Optional parameters must appear after all required parameters
throw new NotImplementedException();
}
//Your Solution
internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection = "")
{
//Just make the sortDirection as optional Parameter
throw new NotImplementedException();
}
// Another Solution
internal void Print(List<Student> list, int page, int size, [Optional, DefaultParameterValue("Name")] string sortBy, string sortDirection)
{
// No Error, Its uses Reflection
throw new NotImplementedException();
}
}
public class Student
{
public void PrintList()
{
var wg = new WebGrid();
wg.Print(new List<Student>(), 1, 100, "Name", "ASC");
}
}
///Called Class
public class WebGrid
{
//Main Method
internal void Print(List<Student> list, int page, int size, string sortBy, string sortDirection)
{
//No Error
throw new NotImplementedException();
}
//You Want
internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection)
{
//Error , Optional parameters must appear after all required parameters
throw new NotImplementedException();
}
//Your Solution
internal void Print(List<Student> list, int page, int size, string sortBy = "Name", string sortDirection = "")
{
//Just make the sortDirection as optional Parameter
throw new NotImplementedException();
}
// Another Solution
internal void Print(List<Student> list, int page, int size, [Optional, DefaultParameterValue("Name")] string sortBy, string sortDirection)
{
// No Error, Its uses Reflection
throw new NotImplementedException();
}
}
Color Your Web Page
Right click on Page> Inspect Element> Console> Paste code> Press Enter
Your widow will be colored
----------------------------------------------------------------------------------------------------
Your widow will be colored
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------[].forEach.call($$("*"),function(a){a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16)})
RDLC Report Footer Problem in DOC and PDF
Write following code
="Page " & Globals!PageNumber & " of " & Globals!TotalPages
instead of
="Page " + Globals!PageNumber.ToString() + " of " + Globals!TotalPages.ToString()
i. e. : replace + sign with &
and remove ToString() casting
="Page " & Globals!PageNumber & " of " & Globals!TotalPages
instead of
="Page " + Globals!PageNumber.ToString() + " of " + Globals!TotalPages.ToString()
i. e. : replace + sign with &
and remove ToString() casting
Language List for Dropdown List(HTML)
<select name="nationality">
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
<option value="armenian">Armenian</option>
<option value="australian">Australian</option>
<option value="austrian">Austrian</option>
<option value="azerbaijani">Azerbaijani</option>
<option value="bahamian">Bahamian</option>
<option value="bahraini">Bahraini</option>
<option value="bangladeshi">Bangladeshi</option>
<option value="barbadian">Barbadian</option>
<option value="barbudans">Barbudans</option>
<option value="batswana">Batswana</option>
<option value="belarusian">Belarusian</option>
<option value="belgian">Belgian</option>
<option value="belizean">Belizean</option>
<option value="beninese">Beninese</option>
<option value="bhutanese">Bhutanese</option>
<option value="bolivian">Bolivian</option>
<option value="bosnian">Bosnian</option>
<option value="brazilian">Brazilian</option>
<option value="british">British</option>
<option value="bruneian">Bruneian</option>
<option value="bulgarian">Bulgarian</option>
<option value="burkinabe">Burkinabe</option>
<option value="burmese">Burmese</option>
<option value="burundian">Burundian</option>
<option value="cambodian">Cambodian</option>
<option value="cameroonian">Cameroonian</option>
<option value="canadian">Canadian</option>
<option value="cape verdean">Cape Verdean</option>
<option value="central african">Central African</option>
<option value="chadian">Chadian</option>
<option value="chilean">Chilean</option>
<option value="chinese">Chinese</option>
<option value="colombian">Colombian</option>
<option value="comoran">Comoran</option>
<option value="congolese">Congolese</option>
<option value="costa rican">Costa Rican</option>
<option value="croatian">Croatian</option>
<option value="cuban">Cuban</option>
<option value="cypriot">Cypriot</option>
<option value="czech">Czech</option>
<option value="danish">Danish</option>
<option value="djibouti">Djibouti</option>
<option value="dominican">Dominican</option>
<option value="dutch">Dutch</option>
<option value="east timorese">East Timorese</option>
<option value="ecuadorean">Ecuadorean</option>
<option value="egyptian">Egyptian</option>
<option value="emirian">Emirian</option>
<option value="equatorial guinean">Equatorial Guinean</option>
<option value="eritrean">Eritrean</option>
<option value="estonian">Estonian</option>
<option value="ethiopian">Ethiopian</option>
<option value="fijian">Fijian</option>
<option value="filipino">Filipino</option>
<option value="finnish">Finnish</option>
<option value="french">French</option>
<option value="gabonese">Gabonese</option>
<option value="gambian">Gambian</option>
<option value="georgian">Georgian</option>
<option value="german">German</option>
<option value="ghanaian">Ghanaian</option>
<option value="greek">Greek</option>
<option value="grenadian">Grenadian</option>
<option value="guatemalan">Guatemalan</option>
<option value="guinea-bissauan">Guinea-Bissauan</option>
<option value="guinean">Guinean</option>
<option value="guyanese">Guyanese</option>
<option value="haitian">Haitian</option>
<option value="herzegovinian">Herzegovinian</option>
<option value="honduran">Honduran</option>
<option value="hungarian">Hungarian</option>
<option value="icelander">Icelander</option>
<option value="indian">Indian</option>
<option value="indonesian">Indonesian</option>
<option value="iranian">Iranian</option>
<option value="iraqi">Iraqi</option>
<option value="irish">Irish</option>
<option value="israeli">Israeli</option>
<option value="italian">Italian</option>
<option value="ivorian">Ivorian</option>
<option value="jamaican">Jamaican</option>
<option value="japanese">Japanese</option>
<option value="jordanian">Jordanian</option>
<option value="kazakhstani">Kazakhstani</option>
<option value="kenyan">Kenyan</option>
<option value="kittian and nevisian">Kittian and Nevisian</option>
<option value="kuwaiti">Kuwaiti</option>
<option value="kyrgyz">Kyrgyz</option>
<option value="laotian">Laotian</option>
<option value="latvian">Latvian</option>
<option value="lebanese">Lebanese</option>
<option value="liberian">Liberian</option>
<option value="libyan">Libyan</option>
<option value="liechtensteiner">Liechtensteiner</option>
<option value="lithuanian">Lithuanian</option>
<option value="luxembourger">Luxembourger</option>
<option value="macedonian">Macedonian</option>
<option value="malagasy">Malagasy</option>
<option value="malawian">Malawian</option>
<option value="malaysian">Malaysian</option>
<option value="maldivan">Maldivan</option>
<option value="malian">Malian</option>
<option value="maltese">Maltese</option>
<option value="marshallese">Marshallese</option>
<option value="mauritanian">Mauritanian</option>
<option value="mauritian">Mauritian</option>
<option value="mexican">Mexican</option>
<option value="micronesian">Micronesian</option>
<option value="moldovan">Moldovan</option>
<option value="monacan">Monacan</option>
<option value="mongolian">Mongolian</option>
<option value="moroccan">Moroccan</option>
<option value="mosotho">Mosotho</option>
<option value="motswana">Motswana</option>
<option value="mozambican">Mozambican</option>
<option value="namibian">Namibian</option>
<option value="nauruan">Nauruan</option>
<option value="nepalese">Nepalese</option>
<option value="new zealander">New Zealander</option>
<option value="ni-vanuatu">Ni-Vanuatu</option>
<option value="nicaraguan">Nicaraguan</option>
<option value="nigerien">Nigerien</option>
<option value="north korean">North Korean</option>
<option value="northern irish">Northern Irish</option>
<option value="norwegian">Norwegian</option>
<option value="omani">Omani</option>
<option value="pakistani">Pakistani</option>
<option value="palauan">Palauan</option>
<option value="panamanian">Panamanian</option>
<option value="papua new guinean">Papua New Guinean</option>
<option value="paraguayan">Paraguayan</option>
<option value="peruvian">Peruvian</option>
<option value="polish">Polish</option>
<option value="portuguese">Portuguese</option>
<option value="qatari">Qatari</option>
<option value="romanian">Romanian</option>
<option value="russian">Russian</option>
<option value="rwandan">Rwandan</option>
<option value="saint lucian">Saint Lucian</option>
<option value="salvadoran">Salvadoran</option>
<option value="samoan">Samoan</option>
<option value="san marinese">San Marinese</option>
<option value="sao tomean">Sao Tomean</option>
<option value="saudi">Saudi</option>
<option value="scottish">Scottish</option>
<option value="senegalese">Senegalese</option>
<option value="serbian">Serbian</option>
<option value="seychellois">Seychellois</option>
<option value="sierra leonean">Sierra Leonean</option>
<option value="singaporean">Singaporean</option>
<option value="slovakian">Slovakian</option>
<option value="slovenian">Slovenian</option>
<option value="solomon islander">Solomon Islander</option>
<option value="somali">Somali</option>
<option value="south african">South African</option>
<option value="south korean">South Korean</option>
<option value="spanish">Spanish</option>
<option value="sri lankan">Sri Lankan</option>
<option value="sudanese">Sudanese</option>
<option value="surinamer">Surinamer</option>
<option value="swazi">Swazi</option>
<option value="swedish">Swedish</option>
<option value="swiss">Swiss</option>
<option value="syrian">Syrian</option>
<option value="taiwanese">Taiwanese</option>
<option value="tajik">Tajik</option>
<option value="tanzanian">Tanzanian</option>
<option value="thai">Thai</option>
<option value="togolese">Togolese</option>
<option value="tongan">Tongan</option>
<option value="trinidadian or tobagonian">Trinidadian or Tobagonian</option>
<option value="tunisian">Tunisian</option>
<option value="turkish">Turkish</option>
<option value="tuvaluan">Tuvaluan</option>
<option value="ugandan">Ugandan</option>
<option value="ukrainian">Ukrainian</option>
<option value="uruguayan">Uruguayan</option>
<option value="uzbekistani">Uzbekistani</option>
<option value="venezuelan">Venezuelan</option>
<option value="vietnamese">Vietnamese</option>
<option value="welsh">Welsh</option>
<option value="yemenite">Yemenite</option>
<option value="zambian">Zambian</option>
<option value="zimbabwean">Zimbabwean</option>
</select>
<option value="">-- select one --</option>
<option value="afghan">Afghan</option>
<option value="albanian">Albanian</option>
<option value="algerian">Algerian</option>
<option value="american">American</option>
<option value="andorran">Andorran</option>
<option value="angolan">Angolan</option>
<option value="antiguans">Antiguans</option>
<option value="argentinean">Argentinean</option>
<option value="armenian">Armenian</option>
<option value="australian">Australian</option>
<option value="austrian">Austrian</option>
<option value="azerbaijani">Azerbaijani</option>
<option value="bahamian">Bahamian</option>
<option value="bahraini">Bahraini</option>
<option value="bangladeshi">Bangladeshi</option>
<option value="barbadian">Barbadian</option>
<option value="barbudans">Barbudans</option>
<option value="batswana">Batswana</option>
<option value="belarusian">Belarusian</option>
<option value="belgian">Belgian</option>
<option value="belizean">Belizean</option>
<option value="beninese">Beninese</option>
<option value="bhutanese">Bhutanese</option>
<option value="bolivian">Bolivian</option>
<option value="bosnian">Bosnian</option>
<option value="brazilian">Brazilian</option>
<option value="british">British</option>
<option value="bruneian">Bruneian</option>
<option value="bulgarian">Bulgarian</option>
<option value="burkinabe">Burkinabe</option>
<option value="burmese">Burmese</option>
<option value="burundian">Burundian</option>
<option value="cambodian">Cambodian</option>
<option value="cameroonian">Cameroonian</option>
<option value="canadian">Canadian</option>
<option value="cape verdean">Cape Verdean</option>
<option value="central african">Central African</option>
<option value="chadian">Chadian</option>
<option value="chilean">Chilean</option>
<option value="chinese">Chinese</option>
<option value="colombian">Colombian</option>
<option value="comoran">Comoran</option>
<option value="congolese">Congolese</option>
<option value="costa rican">Costa Rican</option>
<option value="croatian">Croatian</option>
<option value="cuban">Cuban</option>
<option value="cypriot">Cypriot</option>
<option value="czech">Czech</option>
<option value="danish">Danish</option>
<option value="djibouti">Djibouti</option>
<option value="dominican">Dominican</option>
<option value="dutch">Dutch</option>
<option value="east timorese">East Timorese</option>
<option value="ecuadorean">Ecuadorean</option>
<option value="egyptian">Egyptian</option>
<option value="emirian">Emirian</option>
<option value="equatorial guinean">Equatorial Guinean</option>
<option value="eritrean">Eritrean</option>
<option value="estonian">Estonian</option>
<option value="ethiopian">Ethiopian</option>
<option value="fijian">Fijian</option>
<option value="filipino">Filipino</option>
<option value="finnish">Finnish</option>
<option value="french">French</option>
<option value="gabonese">Gabonese</option>
<option value="gambian">Gambian</option>
<option value="georgian">Georgian</option>
<option value="german">German</option>
<option value="ghanaian">Ghanaian</option>
<option value="greek">Greek</option>
<option value="grenadian">Grenadian</option>
<option value="guatemalan">Guatemalan</option>
<option value="guinea-bissauan">Guinea-Bissauan</option>
<option value="guinean">Guinean</option>
<option value="guyanese">Guyanese</option>
<option value="haitian">Haitian</option>
<option value="herzegovinian">Herzegovinian</option>
<option value="honduran">Honduran</option>
<option value="hungarian">Hungarian</option>
<option value="icelander">Icelander</option>
<option value="indian">Indian</option>
<option value="indonesian">Indonesian</option>
<option value="iranian">Iranian</option>
<option value="iraqi">Iraqi</option>
<option value="irish">Irish</option>
<option value="israeli">Israeli</option>
<option value="italian">Italian</option>
<option value="ivorian">Ivorian</option>
<option value="jamaican">Jamaican</option>
<option value="japanese">Japanese</option>
<option value="jordanian">Jordanian</option>
<option value="kazakhstani">Kazakhstani</option>
<option value="kenyan">Kenyan</option>
<option value="kittian and nevisian">Kittian and Nevisian</option>
<option value="kuwaiti">Kuwaiti</option>
<option value="kyrgyz">Kyrgyz</option>
<option value="laotian">Laotian</option>
<option value="latvian">Latvian</option>
<option value="lebanese">Lebanese</option>
<option value="liberian">Liberian</option>
<option value="libyan">Libyan</option>
<option value="liechtensteiner">Liechtensteiner</option>
<option value="lithuanian">Lithuanian</option>
<option value="luxembourger">Luxembourger</option>
<option value="macedonian">Macedonian</option>
<option value="malagasy">Malagasy</option>
<option value="malawian">Malawian</option>
<option value="malaysian">Malaysian</option>
<option value="maldivan">Maldivan</option>
<option value="malian">Malian</option>
<option value="maltese">Maltese</option>
<option value="marshallese">Marshallese</option>
<option value="mauritanian">Mauritanian</option>
<option value="mauritian">Mauritian</option>
<option value="mexican">Mexican</option>
<option value="micronesian">Micronesian</option>
<option value="moldovan">Moldovan</option>
<option value="monacan">Monacan</option>
<option value="mongolian">Mongolian</option>
<option value="moroccan">Moroccan</option>
<option value="mosotho">Mosotho</option>
<option value="motswana">Motswana</option>
<option value="mozambican">Mozambican</option>
<option value="namibian">Namibian</option>
<option value="nauruan">Nauruan</option>
<option value="nepalese">Nepalese</option>
<option value="new zealander">New Zealander</option>
<option value="ni-vanuatu">Ni-Vanuatu</option>
<option value="nicaraguan">Nicaraguan</option>
<option value="nigerien">Nigerien</option>
<option value="north korean">North Korean</option>
<option value="northern irish">Northern Irish</option>
<option value="norwegian">Norwegian</option>
<option value="omani">Omani</option>
<option value="pakistani">Pakistani</option>
<option value="palauan">Palauan</option>
<option value="panamanian">Panamanian</option>
<option value="papua new guinean">Papua New Guinean</option>
<option value="paraguayan">Paraguayan</option>
<option value="peruvian">Peruvian</option>
<option value="polish">Polish</option>
<option value="portuguese">Portuguese</option>
<option value="qatari">Qatari</option>
<option value="romanian">Romanian</option>
<option value="russian">Russian</option>
<option value="rwandan">Rwandan</option>
<option value="saint lucian">Saint Lucian</option>
<option value="salvadoran">Salvadoran</option>
<option value="samoan">Samoan</option>
<option value="san marinese">San Marinese</option>
<option value="sao tomean">Sao Tomean</option>
<option value="saudi">Saudi</option>
<option value="scottish">Scottish</option>
<option value="senegalese">Senegalese</option>
<option value="serbian">Serbian</option>
<option value="seychellois">Seychellois</option>
<option value="sierra leonean">Sierra Leonean</option>
<option value="singaporean">Singaporean</option>
<option value="slovakian">Slovakian</option>
<option value="slovenian">Slovenian</option>
<option value="solomon islander">Solomon Islander</option>
<option value="somali">Somali</option>
<option value="south african">South African</option>
<option value="south korean">South Korean</option>
<option value="spanish">Spanish</option>
<option value="sri lankan">Sri Lankan</option>
<option value="sudanese">Sudanese</option>
<option value="surinamer">Surinamer</option>
<option value="swazi">Swazi</option>
<option value="swedish">Swedish</option>
<option value="swiss">Swiss</option>
<option value="syrian">Syrian</option>
<option value="taiwanese">Taiwanese</option>
<option value="tajik">Tajik</option>
<option value="tanzanian">Tanzanian</option>
<option value="thai">Thai</option>
<option value="togolese">Togolese</option>
<option value="tongan">Tongan</option>
<option value="trinidadian or tobagonian">Trinidadian or Tobagonian</option>
<option value="tunisian">Tunisian</option>
<option value="turkish">Turkish</option>
<option value="tuvaluan">Tuvaluan</option>
<option value="ugandan">Ugandan</option>
<option value="ukrainian">Ukrainian</option>
<option value="uruguayan">Uruguayan</option>
<option value="uzbekistani">Uzbekistani</option>
<option value="venezuelan">Venezuelan</option>
<option value="vietnamese">Vietnamese</option>
<option value="welsh">Welsh</option>
<option value="yemenite">Yemenite</option>
<option value="zambian">Zambian</option>
<option value="zimbabwean">Zimbabwean</option>
</select>
Debug or Run SP in Oracle
Oracle SP
--------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE RPT_MFS_Revised_Journal (
P_JOURNAL_DATE IN DATE := NULL,
cur_OUT IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cur_out FOR
SELECT TO_CHAR (TransactionDate, 'DD/MM/YYYY') AS TransactionDate,
TXCODE,
FROM T_Activity,
WHERE ( (T_Activity.IsRollBack = 0)
OR (T_Activity.IsRollBack = 1
ORDER BY T_Activity.TxID;
END;
/
----------------------------------------------------------------------------------------------------------------------
Suppose
SP Name: RPT_MFS_Revised_Journal
Parameters:
P_JOURNAL_DATE : '10/25/2014'
To Debug SP Write Following Code
---------------------------------------------------------------------
BEGIN
RPT_MFS_Revised_Journal (
:P_JOURNAL_DATE,
:cur_OUT);
END;
---------------------------------------------------------------------
Select code and click [Execute statement] from left side {blue play button}
A Variables window popup. Select date type for [P_JOURNAL_DATE] and input date('10/25/2014') and null for [cur_OUT]
Then click OK.
If Everything ok, then you got actual result.
--------------------------------------------------------------------------------------------------------------------
CREATE OR REPLACE PROCEDURE RPT_MFS_Revised_Journal (
P_JOURNAL_DATE IN DATE := NULL,
cur_OUT IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cur_out FOR
SELECT TO_CHAR (TransactionDate, 'DD/MM/YYYY') AS TransactionDate,
TXCODE,
FROM T_Activity,
WHERE ( (T_Activity.IsRollBack = 0)
OR (T_Activity.IsRollBack = 1
ORDER BY T_Activity.TxID;
END;
/
----------------------------------------------------------------------------------------------------------------------
Suppose
SP Name: RPT_MFS_Revised_Journal
Parameters:
P_JOURNAL_DATE : '10/25/2014'
To Debug SP Write Following Code
---------------------------------------------------------------------
BEGIN
RPT_MFS_Revised_Journal (
:P_JOURNAL_DATE,
:cur_OUT);
END;
---------------------------------------------------------------------
Select code and click [Execute statement] from left side {blue play button}
A Variables window popup. Select date type for [P_JOURNAL_DATE] and input date('10/25/2014') and null for [cur_OUT]
Then click OK.
If Everything ok, then you got actual result.
Oracle Column type in SP Parameter
p_FILEEXTENSION IN USACCTFLINFO.FILEEXTENSION%type := NULL
SP Parameter Name: p_FILEEXTENSION
Table Name: USACCTFLINFO
Table Column Name: FILEEXTENSION
If you want parameter type as column type then just write above code in SP
SP Parameter Name: p_FILEEXTENSION
Table Name: USACCTFLINFO
Table Column Name: FILEEXTENSION
If you want parameter type as column type then just write above code in SP
Text area Max Length by Jquery in asp.net
HTML
<asp:TextBox ID="txtmailingaddress1" runat="server" CssClass="textboxNormalLeftAligned inputField textarea200" TextMode="MultiLine" MaxLength="15" onkeyDown="checkTextAreaMaxLength2(this,event,'20');" />
From Last character will be deleted.
$('.textarea200').keyup(function () {
var limit = 200; // parseInt($(this).attr('maxlength'));
var text = $(this).val();
var chars = text.length;
if (chars > limit) {
var new_text = text.substr(0, limit);
$(this).val(new_text);
}
});
-----------------------------------------------------------------------------------------
Character will not deleted but you can input Enter between word.
$("textarea.textarea2002").keydown(function (event) {
var limit = 200;
var text = $(this).val();
var chars = text.length;
alert(chars);
if ((event.keyCode == null) || (event.keyCode == 0) || (event.keyCode == 8) || (event.keyCode == 9) || (event.keyCode == 13) || (event.keyCode == 27) || (event.keyCode == 33) || (event.keyCode == 34) || (event.keyCode == 35) || (event.keyCode == 36) || (event.keyCode == 37) || (event.keyCode == 38) || (event.keyCode == 39) || (event.keyCode == 40) || (event.keyCode == 46)) {} else {
if (chars <= limit) {} else {
event.preventDefault();
}
}
});
-----------------------------------------------------------------------------------------
You cant enter any value between string after 200 character length
function checkTextAreaMaxLength(textBox, e, mLen) {
var mLen = textBox["MaxLength"];
if (null == mLen)
mLen = length;
var maxLength = parseInt(mLen);
if (!checkSpecialKeys(e)) {
if (textBox.value.length > maxLength - 1) {
if (window.event) //IE
e.returnValue = false;
else //Firefox
e.preventDefault();
}
}
}
function checkSpecialKeys(e) {
if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) {
return false;
} else {
return true;
}
}
-----------------------------------------------------------------------------------------
Run in JsFiddle:
http://jsfiddle.net/skpaik/L9brP
<asp:TextBox ID="txtmailingaddress1" runat="server" CssClass="textboxNormalLeftAligned inputField textarea200" TextMode="MultiLine" MaxLength="15" onkeyDown="checkTextAreaMaxLength2(this,event,'20');" />
From Last character will be deleted.
$('.textarea200').keyup(function () {
var limit = 200; // parseInt($(this).attr('maxlength'));
var text = $(this).val();
var chars = text.length;
if (chars > limit) {
var new_text = text.substr(0, limit);
$(this).val(new_text);
}
});
-----------------------------------------------------------------------------------------
Character will not deleted but you can input Enter between word.
$("textarea.textarea2002").keydown(function (event) {
var limit = 200;
var text = $(this).val();
var chars = text.length;
alert(chars);
if ((event.keyCode == null) || (event.keyCode == 0) || (event.keyCode == 8) || (event.keyCode == 9) || (event.keyCode == 13) || (event.keyCode == 27) || (event.keyCode == 33) || (event.keyCode == 34) || (event.keyCode == 35) || (event.keyCode == 36) || (event.keyCode == 37) || (event.keyCode == 38) || (event.keyCode == 39) || (event.keyCode == 40) || (event.keyCode == 46)) {} else {
if (chars <= limit) {} else {
event.preventDefault();
}
}
});
-----------------------------------------------------------------------------------------
You cant enter any value between string after 200 character length
function checkTextAreaMaxLength(textBox, e, mLen) {
var mLen = textBox["MaxLength"];
if (null == mLen)
mLen = length;
var maxLength = parseInt(mLen);
if (!checkSpecialKeys(e)) {
if (textBox.value.length > maxLength - 1) {
if (window.event) //IE
e.returnValue = false;
else //Firefox
e.preventDefault();
}
}
}
function checkSpecialKeys(e) {
if (e.keyCode != 8 && e.keyCode != 46 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40) {
return false;
} else {
return true;
}
}
-----------------------------------------------------------------------------------------
Run in JsFiddle:
http://jsfiddle.net/skpaik/L9brP
Run Stored Procedure in Oracle Toad Client
--- Procedure Name 'GetCashAccountByUserNumber'
--------------------------------------------------------------
CREATE OR REPLACE PROCEDURE GetCashAccountByUserNumber
(p_CREATEDBY IN NUMBER := NULL,
p_CREATEDDATE IN DATE := NULL,
p_UPDATEDBY IN NUMBER := NULL,
p_UPDATEDDATE IN DATE := NULL,
p_IPADDRESS VARCHAR2 := NULL,
p_FORMID IN NUMBER := NULL,
p_UserNumber IN NUMBER DEFAULT NULL,
p_BankKey IN NUMBER DEFAULT NULL,
cur_OUT IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cur_OUT FOR
SELECT UserAccounts.UserKey,
UserAccounts.AccountTypeKey,
UserAccounts.UserNumber,
SysAcct.SystemAccountID,
SysAcctRefUsAcct.SystemAccountRefID,
SysAcctRefUsAcct.UserCurrentBalance,
SysAcctRefUsAcct.BlockedAmount,
SysAcctRefUsAcct.IsVAT,
SysAcctRefUsAcct.IsCOM,
SysAcctRefUsAcct.IsActive,
SysAcctRefUsAcct.ParentCode,
SysAcct.AccountNumber,
SysAcct.AccountDescription,
UserAccounts.UserNumber ParentUserNumber
FROM SysAcct
JOIN SysAcctRefUsAcct
ON SysAcct.SystemAccountID = SysAcctRefUsAcct.SystemAccountID
JOIN UserAccounts
ON SysAcctRefUsAcct.UserKey = UserAccounts.UserKey
JOIN Bank
ON SysAcctRefUsAcct.BankKey = Bank.BankKey
AND UserAccounts.BankKey = Bank.BankKey
WHERE UserAccounts.UserNumber = p_UserNumber
AND SysAcct.AccountNumber = '5008'
AND UserAccounts.BankKey = p_BankKey
ORDER BY UserAccounts.UserKey;
END;
/
--------------------------------------------------------------
To Run Open Editor
Write following code
BEGIN
E_GetCashAccountByUserNumber
(
:p_CREATEDBY,
:p_CREATEDDATE,
:p_UPDATEDBY,
:p_UPDATEDDATE,
:p_IPADDRESS,
:p_FORMID,
:p_UserNumber,
:p_BankKey,
:cur_OUT
);
END;
--------------------------------------------------------------
Then Ctrl+A for select all code
Click on 'Excecute statement' Button
Give all Value type and Value
Press OK
--------------------------------------------------------------
CREATE OR REPLACE PROCEDURE GetCashAccountByUserNumber
(p_CREATEDBY IN NUMBER := NULL,
p_CREATEDDATE IN DATE := NULL,
p_UPDATEDBY IN NUMBER := NULL,
p_UPDATEDDATE IN DATE := NULL,
p_IPADDRESS VARCHAR2 := NULL,
p_FORMID IN NUMBER := NULL,
p_UserNumber IN NUMBER DEFAULT NULL,
p_BankKey IN NUMBER DEFAULT NULL,
cur_OUT IN OUT SYS_REFCURSOR)
AS
BEGIN
OPEN cur_OUT FOR
SELECT UserAccounts.UserKey,
UserAccounts.AccountTypeKey,
UserAccounts.UserNumber,
SysAcct.SystemAccountID,
SysAcctRefUsAcct.SystemAccountRefID,
SysAcctRefUsAcct.UserCurrentBalance,
SysAcctRefUsAcct.BlockedAmount,
SysAcctRefUsAcct.IsVAT,
SysAcctRefUsAcct.IsCOM,
SysAcctRefUsAcct.IsActive,
SysAcctRefUsAcct.ParentCode,
SysAcct.AccountNumber,
SysAcct.AccountDescription,
UserAccounts.UserNumber ParentUserNumber
FROM SysAcct
JOIN SysAcctRefUsAcct
ON SysAcct.SystemAccountID = SysAcctRefUsAcct.SystemAccountID
JOIN UserAccounts
ON SysAcctRefUsAcct.UserKey = UserAccounts.UserKey
JOIN Bank
ON SysAcctRefUsAcct.BankKey = Bank.BankKey
AND UserAccounts.BankKey = Bank.BankKey
WHERE UserAccounts.UserNumber = p_UserNumber
AND SysAcct.AccountNumber = '5008'
AND UserAccounts.BankKey = p_BankKey
ORDER BY UserAccounts.UserKey;
END;
/
--------------------------------------------------------------
To Run Open Editor
Write following code
BEGIN
E_GetCashAccountByUserNumber
(
:p_CREATEDBY,
:p_CREATEDDATE,
:p_UPDATEDBY,
:p_UPDATEDDATE,
:p_IPADDRESS,
:p_FORMID,
:p_UserNumber,
:p_BankKey,
:cur_OUT
);
END;
--------------------------------------------------------------
Then Ctrl+A for select all code
Click on 'Excecute statement' Button
Give all Value type and Value
Press OK
SQL SERVER – Introduction to Rollup Clause
Create a Database
Then new Script
Then Fire this.
------------------------------------------------------------------------------
CREATE TABLE tblPopulation (
Country VARCHAR(100),
[State] VARCHAR(100),
City VARCHAR(100),
[Population (in Millions)] INT)
GO
INSERT INTO tblPopulation VALUES('India', 'Delhi','East Delhi',9 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','South Delhi',8 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','North Delhi',5.5)
INSERT INTO tblPopulation VALUES('India', 'Delhi','West Delhi',7.5)
INSERT INTO tblPopulation VALUES('India','Karnataka','Bangalore',9.5)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Belur',2.5)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Manipal',1.5)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Mumbai',30)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Pune',20)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nagpur',11 )
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nashik',6.5)
GO
---To Display
SELECT
ISNULL(Country,'All Country') AS Country,
ISNULL([State],'All State') AS State,
ISNULL(City,'All City') AS City,SUM ([Population (in Millions)]) AS [Population (in Millions)]FROM tblPopulationGROUP BY Country,[State],City WITH ROLLUP
Details: http://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause
Then new Script
Then Fire this.
------------------------------------------------------------------------------
CREATE TABLE tblPopulation (
Country VARCHAR(100),
[State] VARCHAR(100),
City VARCHAR(100),
[Population (in Millions)] INT)
GO
INSERT INTO tblPopulation VALUES('India', 'Delhi','East Delhi',9 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','South Delhi',8 )
INSERT INTO tblPopulation VALUES('India', 'Delhi','North Delhi',5.5)
INSERT INTO tblPopulation VALUES('India', 'Delhi','West Delhi',7.5)
INSERT INTO tblPopulation VALUES('India','Karnataka','Bangalore',9.5)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Belur',2.5)
INSERT INTO tblPopulation VALUES('India', 'Karnataka','Manipal',1.5)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Mumbai',30)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Pune',20)
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nagpur',11 )
INSERT INTO tblPopulation VALUES('India', 'Maharastra','Nashik',6.5)
GO
---To Display
SELECT
ISNULL(Country,'All Country') AS Country,
ISNULL([State],'All State') AS State,
ISNULL(City,'All City') AS City,SUM ([Population (in Millions)]) AS [Population (in Millions)]FROM tblPopulationGROUP BY Country,[State],City WITH ROLLUP
Details: http://blog.sqlauthority.com/2010/02/24/sql-server-introduction-to-rollup-clause
Upload Excel to SQL Server using OleDbConnection
importExcel.aspx Page
===================================================================== <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="importExcel.aspx.cs" Inherits="Eisk.Web.admin.importExcel" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Upload Excel File to Database </title>
</head>
<body>
<form id="form1" runat="server">
<asp:FileUpload ID="fluInput" runat="server" />
<asp:Button ID="btnImport" Text="Import" runat="server" OnClick="btnUploadFile_Click"
CssClass="button medium green" />
</form>
</body>
</html>
=====================================================================
Code Behind importExcel.aspx.cs
=====================================================================
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OleDb;
using System.IO;
using Eisk.BusinessEntities;
using Eisk.BusinessLogicLayer;
namespace Eisk.Web.admin
{
public partial class importExcel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnUploadFile_Click(object sender, EventArgs e)
{
ConvertFile();
}
protected void ConvertFile()
{
if (fluInput.HasFile)
{
string strFileName = Server.HtmlEncode(fluInput.FileName);
string strExtension = Path.GetExtension(strFileName);
if (strExtension != ".xls" && strExtension != ".xlsx")
{
Response.Write("<script>alert('Please select a Excel spreadsheet to import!');</script>");
return;
}
string strUploadFileName = "~/admin/Excell/" + DateTime.Now.ToString("yyyyMMddHHmmss") + strExtension;
strUploadFileName = Server.MapPath(strUploadFileName);
fluInput.SaveAs(strUploadFileName);
string connectionString = "";
if (strExtension == ".xls")
{
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + strUploadFileName + ";Extended Properties='Excel 8.0;HDR=YES;'";
}
else
{
connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strUploadFileName + ";Extended Properties='Excel 12.0 Xml;HDR=YES;'";
}
try
{
OleDbConnection connection = new OleDbConnection(connectionString);
connection.Open();
string sheetName = "Sheet1";
string query = "SELECT * FROM [" + sheetName + "$]";
OleDbDataAdapter adapter = new OleDbDataAdapter(query, connection);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
adapter.Fill(ds);
dt = ds.Tables[0];
adapter.Fill(dt);
connection.Close();
int number_of_columns = dt.Columns.Count;
int number_of_rows = ds.Tables[0].Rows.Count / 2;
string[,] sheetEntries = new string[number_of_rows, number_of_columns];
string[] columnNames = new string[number_of_columns];
int startingColumn = 1;
for (int i = startingColumn; i < number_of_rows; i++)
{
for (int j = 0; j < number_of_columns; j++)
sheetEntries[i, j] = dt.Rows[i].ItemArray.GetValue(j).ToString();
}
List<ActivationCode> activationCodeList = CovertToList(sheetEntries, number_of_columns, number_of_rows);
ExportToSQLServerActivationCode(activationCodeList);
if (File.Exists(strUploadFileName))
{
File.Delete(strUploadFileName);
}
}
catch (Exception ex)
{
}
}
}
private List<ActivationCode> CovertToList(string[,] sheetEntries, int number_of_columns, int number_of_rows)
{
List<ActivationCode> aclist = new List<ActivationCode>();
ActivationCode aCode = null;
DateTime toDay = DateTime.Now;
for (int i = 0; i < number_of_rows; i++)
{
aCode = new ActivationCode();
string activationCodeName = StringNullOrEmptyChecking(sheetEntries[i, 2]);
string servicePlanSKU = StringNullOrEmptyChecking(sheetEntries[i, 5]);
if (!string.IsNullOrEmpty(activationCodeName) && !string.IsNullOrEmpty(servicePlanSKU))
{
aCode.ActivationCodeName = activationCodeName;
aCode.ServicePlanSKU = servicePlanSKU;
aCode.MinProductsNo = 1;
string maxProductsNo = StringNullOrEmptyChecking(sheetEntries[i, 11]);
if (!string.IsNullOrEmpty(maxProductsNo))
{
aCode.MaxProductsNo = Convert.ToInt16(maxProductsNo);
}
else
{
aCode.MaxProductsNo = 1;
}
aCode.IsUsed = false;
aCode.UploadDate = toDay;
aclist.Add(aCode);
}
}
return aclist;
}
private string StringNullOrEmptyChecking(object value)
{
if (value == null)
return null;
string returnValue = null;
if (value != null)
{
returnValue = value.ToString();
}
if (value == "")
{
returnValue = null;
}
return returnValue;
}
private void ExportToSQLServerActivationCode(List<ActivationCode> activationCodeList)
{
ActivationCodeBLL activationCodeBLL = new ActivationCodeBLL();
ActivationCodeRejectedBLL activationCodeRejectedBLL = new ActivationCodeRejectedBLL();
List<ActivationCode> allActivationCodeList = activationCodeBLL.GetAllActivationCodes();
List<ActivationCode> allActivationCodeListSelected = new List<ActivationCode>();
List<ActivationCodeRejected> activationCodeRejectedList = new List<ActivationCodeRejected>();
foreach (ActivationCode item in activationCodeList)
{
ActivationCode isExists = allActivationCodeList.Find(x => x.ActivationCodeName == item.ActivationCodeName);
if (isExists == null)
{
allActivationCodeListSelected.Add(item);
}
else
{
ActivationCodeRejected activationCodeRejected = new ActivationCodeRejected();
activationCodeRejected.ActivationCodeName = item.ActivationCodeName;
activationCodeRejected.ServicePlanSKU = item.ServicePlanSKU;
activationCodeRejected.MinProductsNo = item.MinProductsNo;
activationCodeRejected.MaxProductsNo = item.MaxProductsNo;
activationCodeRejected.IsUsed = item.IsUsed;
activationCodeRejected.UploadDate = item.UploadDate;
activationCodeRejectedList.Add(activationCodeRejected);
}
}
foreach (var item in allActivationCodeListSelected)
{
activationCodeBLL.CreateNewActivationCode(item);
}
foreach (var item in activationCodeRejectedList)
{
activationCodeRejectedBLL.CreateNewActivationCodeRejected(item);
}
}
}
}
Subscribe to:
Posts (Atom)