Sunday, February 26, 2017
Wednesday, February 22, 2017
SQL JOIN
SQL JOIN:
INNER JOIN: returns rows when there is a match in both tables.
LEFT JOIN: returns all rows from the left table, even if there are no matches in the right table.
RIGHT JOIN: returns all rows from the right table, even if there are no matches in the left table.
FULL JOIN: returns rows when there is a match in one of the tables.
SELF JOIN: is used to join a table to itself as if the table were two tables, temporarily renaming at least one table in the SQL statement.
CARTESIAN JOIN: returns the Cartesian product of the sets of records from the two or more joined tables.
WE can take each first four joins in Details :
We have two tables with the following values.
TableA
id firstName lastName
.......................................
1 arun prasanth
2 ann antony
3 sruthy abc
6 new abc
TableB
id2 age Place
................
1 24 kerala
2 24 usa
3 25 ekm
5 24 chennai
....................................................................
INNER JOIN
Note :it gives the intersection of the two tables, i.e. rows they have common in TableA and TableB
Syntax
SELECT table1.column1, table2.column2...
FROM table1
INNER JOIN table2
ON table1.common_field = table2.common_field;
Apply it in our sample table :
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place
FROM TableA
INNER JOIN TableB
ON TableA.id = TableB.id2;
Result Will Be
firstName lastName age Place
..............................................
arun prasanth 24 kerala
ann antony 24 usa
sruthy abc 25 ekm
LEFT JOIN
Note : will give all selected rows in TableA, plus any common selected rows in TableB.
Syntax
SELECT table1.column1, table2.column2...
FROM table1
LEFT JOIN table2
ON table1.common_field = table2.common_field;
Apply it in our sample table :
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place
FROM TableA
LEFT JOIN TableB
ON TableA.id = TableB.id2;
Result
firstName lastName age Place
...............................................................................
arun prasanth 24 kerala
ann antony 24 usa
sruthy abc 25 ekm
new abc NULL NULL
RIGHT JOIN
Note : will give all selected rows in TableB, plus any common selected rows in TableA.
Syntax
SELECT table1.column1, table2.column2...
FROM table1
RIGHT JOIN table2
ON table1.common_field = table2.common_field;
Apply it in our sample table :
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place
FROM TableA
RIGHT JOIN TableB
ON TableA.id = TableB.id2;
Result
firstName lastName age Place
...............................................................................
arun prasanth 24 kerala
ann antony 24 usa
sruthy abc 25 ekm
NULL NULL 24 chennai
FULL JOIN
Note : It is same as union operation, it will return all selected values from both tables.
Syntax
SELECT table1.column1, table2.column2...
FROM table1
FULL JOIN table2
ON table1.common_field = table2.common_field;
Apply it in our sample table :
SELECT TableA.firstName,TableA.lastName,TableB.age,TableB.Place
FROM TableA
FULL JOIN TableB
ON TableA.id = TableB.id2;
Result
firstName lastName age Place
...............................................................................
arun prasanth 24 kerala
ann antony 24 usa
sruthy abc 25 ekm
new abc NULL NULL
NULL NULL 24 chennai
Friday, February 10, 2017
Mail System API in create C#
Mail System API in create C#
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
namespace CationHRManagementSystem.WebAPI
{
public class SendMailAPI
{
public void SendEmail(string emailID,string mailSubject,string mailBody)
{
//MailMessage("From","To")
using (MailMessage mm = new MailMessage("cationtest@gmail.com", emailID))
{
mm.Subject = mailSubject;
mm.Body = mailBody;
//if (fuAttachment.HasFile)
//{
// string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
// mm.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
//}
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 465;
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("cationtest@gmail.com", "test_12345");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
}
}
Use of Mail API
using CationHRManagementSystem.WebAPI;
protected void sendMail()
{
SendMailAPI mailObj = new SendMailAPI();
mailObj.SendEmail(txtTo.Text, txtSubject.Text, txtBody.InnerText);
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Web;
namespace CationHRManagementSystem.WebAPI
{
public class SendMailAPI
{
public void SendEmail(string emailID,string mailSubject,string mailBody)
{
//MailMessage("From","To")
using (MailMessage mm = new MailMessage("cationtest@gmail.com", emailID))
{
mm.Subject = mailSubject;
mm.Body = mailBody;
//if (fuAttachment.HasFile)
//{
// string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
// mm.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
//}
mm.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Port = 465;
smtp.EnableSsl = true;
NetworkCredential NetworkCred = new NetworkCredential("cationtest@gmail.com", "test_12345");
smtp.UseDefaultCredentials = true;
smtp.Credentials = NetworkCred;
smtp.Port = 587;
smtp.Send(mm);
}
}
}
}
Use of Mail API
using CationHRManagementSystem.WebAPI;
protected void sendMail()
{
SendMailAPI mailObj = new SendMailAPI();
mailObj.SendEmail(txtTo.Text, txtSubject.Text, txtBody.InnerText);
}
Wednesday, February 1, 2017
Validate Upload file type using Javascript
Validate Upload file type using Javascript
function()
{
var fup = document.getElementById('FileName');
var fileName = fup.value;
var ext = fileName.substring(fileName.lastIndexOf('.') + 1);
if (ext == "pdf" || ext == "JPEG" || ext == "jpeg" || ext == "jpg" || ext == "JPG") {
return true;
}
else {
alert("Upload pdf or images only");
fup.focus();
return false;
}
}
Function for close Popup Window using Javascript
function()
{
window.close();
}
Thursday, January 26, 2017
Insert Data in Parameterise to Database using Asp.net webui
Insert Data in Parameterise to Database using Asp.net webui
C# Code
protected void btnSave_Click(object sender, EventArgs e)
{
string Vission = txtvision.InnerText;
string Mission = txtmission.InnerText;
string values = txtvalues.InnerText;
string status = ddlStatus.SelectedValue;
if (Vission != "<br>" && Mission != "<br>" && values != "<br>" && status != "")
{
MySqlConnection con = new MySqlConnection(conStr);
string str = "insert into vision_mst(vision_text,mission_text,values_text,vision_status,added_on,added_by) values(@Vission,@Mission,@values,@status,now(),'" + Session["USER_ID"].ToString() + "')";
MySqlCommand cmd = new MySqlCommand(str,con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@Vission", Vission);
cmd.Parameters.AddWithValue("@Mission", Mission);
cmd.Parameters.AddWithValue("@values", values);
cmd.Parameters.AddWithValue("@status", status);
con.Open();
int i = cmd.ExecuteNonQuery();
con.Close();
if (i > 0)
{
lblMsg.Text = "Record has been added succesfully";
lblMsg.CssClass = "successMsg";
}
else
{
lblMsg.Text = "Error in record insertion";
lblMsg.CssClass = "errorMsg";
}
txtvision.InnerText = "";
txtmission.InnerText = "";
txtvalues.InnerText = "";
ddlStatus.SelectedIndex = 0;
}
else
{
lblMsg.Text = "Please enter text in Mandatory Fields";
lblMsg.CssClass = "errorMsg";
}
}
ASP.Net
<%@ Page Title="vision Add" Language="C#" MasterPageFile="~/Admin.Master" AutoEventWireup="true" CodeBehind="VisionAddition.aspx.cs" Inherits="CationHRManagementSystem.VisionAddition" ValidateRequest="false" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<link href="css/cssCommon.css" rel="stylesheet" />
<script type="text/javascript" src="http://js.nicedit.com/nicEdit-latest.js"></script>
<script type="text/javascript">
//<![CDATA[
bkLib.onDomLoaded(function () { nicEditors.allTextAreas() });
//]]>
</script>
<div>
<table width="100%" style="background-color: lightgray;">
<tr>
<td width="100%" class="pageHeadertext-style">Vision: Create</td>
</tr>
</table>
<table style="margin-left: 40px; margin-top: 40px; margin-bottom: 40px;">
<tr>
<td></td>
<td align="right">
<asp:Button ID="btnBack" runat="server" Text="Back" OnClick="btnBack_Click" Style="margin-left: 0px" CssClass="button-style" />
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Label ID="lblMsg" runat="server" CssClass="labeltext-style"></asp:Label>
</td>
</tr>
<%-- <tr>
<td class="text-style"> Organization</td>
<td>
<asp:TextBox ID="txtOrg" runat="server" CssClass="textbox-style"></asp:TextBox>
</td>
</tr>--%>
<tr>
<td class="textfield xui-required" align="right">Vision<%--<span class="redTxt">* </span>--%></td>
<td>
<textarea id="txtvision" runat="server" rows="5" cols="55" class="EULAtextarea-style"></textarea>
</td>
</tr>
<tr>
<td class="textfield xui-required" align="right">Mission<%--<span class="redTxt">* </span>--%></td>
<td>
<textarea id="txtmission" runat="server" rows="5" cols="55" class="EULAtextarea-style"></textarea>
</td>
</tr>
<tr>
<td class="textfield xui-required" align="right">Value<%--<span class="redTxt">* </span>--%></td>
<td>
<textarea id="txtvalues" runat="server" rows="8" cols="55" class="EULAtextarea-style"></textarea>
</td>
</tr>
<tr>
<td class="textfield xui-required" align="right">Status <%--<span class="redTxt">* </span>--%></td>
<td>
<asp:DropDownList ID="ddlStatus" runat="server" CssClass="dropdownsmall-style">
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" CssClass="button-style" ></asp:Button>
<%--<asp:Button ID="btnReset" runat="server" Text="Reset" OnClick="btnReset_Click" CssClass="button-style"></asp:Button>--%>
</td>
</tr>
</table>
</div>
</asp:Content>
Output
Wednesday, January 25, 2017
Searching Method
Searching Method:
C# Code
protected void btnSearch_Click(object sender, EventArgs e)
{
showdata(" "); // this function for show grid
}
if (txtSearch.Text.ToString().Trim().Length > 0)
{
sqlStr += " and concat(u.USER_SAL,' ',u.USER_FIRSTNAME,' ',u.USER_LASTNAME) LIKE '%" + txtSearch.Text.Trim().ToLower() + "%'";
}
ASP.Net Code
<asp:TextBox ID="txtSearch" runat="server" class="searchbox-style" placeholder="Enter JD Name"></asp:TextBox>
Subscribe to:
Posts (Atom)