Contact Form
Jquery Dynamic Drop down fill
function toasterall(headingtext, Bodyttext, Typealert) {
$.toast({
heading: headingtext,
text: Bodyttext,
position: 'top-right',
loaderBg: '#ff6849',
icon: Typealert,
hideAfter: 3000,
stack: 6
});
}
var mybesturl = window.location.protocol + "//" + window.location.host + "/" + window.location.pathname.split("/")[1] + "/";
if (mybesturl.indexOf("https://localhost:5001/") != -1) {
// console.log(str2 + " found");
mybesturl = window.location.protocol + "//" + window.location.host + "/" ;
}
function LoadddlSetup(id, Meassage, VType) {
$(id).empty();
$.ajax({
url: mybesturl +"Setup/LoadGetbyShow?VType=" + VType,
data: {},
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
error: function (xhr, textStatus, errorThrown) {
toasterall('Error', " An error occurred. Get " + Meassage + " ", 'error');
//if (xhr.status === 401) {
// window.location.href = myPathLogin;
//}
},
success: function (result) {
// console.log(result.Reslst);
if (result != null) {
if (result.MessageType === true) {
var data=result.Reslst;
var optionhtml1 = '<option value="">' + "Select " + Meassage + "" + '</option>';
$(id).append(optionhtml1);
$.each(data, function (i) {
var optionhtml = '<option value="' +
data[i].VID + '">' + data[i].VName + '</option>';
$(id).append(optionhtml);
});
} else {
toasterall('Error', result.Message, 'error');
}
}
}
});
}
function LoadddlSetupSelected(id, Meassage, VType, SelectedVal) {
$(id).empty();
$.ajax({
url: mybesturl + "Setup/LoadGetbyShow?VType=" + VType,
data: {},
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
error: function (xhr, textStatus, errorThrown) {
toasterall('Error', " An error occurred. Get " + Meassage + " ", 'error');
//if (xhr.status === 401) {
// window.location.href = myPathLogin;
//}
},
success: function (result) {
//console.log(result.Reslst);
if (result != null) {
if (result.MessageType === true) {
var data = result.Reslst;
var optionhtml1 = '<option value="">' + "Select " + Meassage + "" + '</option>';
$(id).append(optionhtml1);
$.each(data, function (i) {
var optionhtml = '<option value="' +
data[i].VID + '">' + data[i].VName + '</option>';
$(id).append(optionhtml);
});
$(id).val(SelectedVal);
} else {
toasterall('Error', result.Message, 'error');
}
}
}
});
}
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header text-uppercase">
<div class="divtitle">
Add Admin Expense Voucher
</div>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<form id="frmAddAdminExpenseVoucher">
<div class="form-group row">
<label class="col-sm-2 col-form-label">Code</label>
<div class="col-sm-4">
<input type="text" class="form-control form-control-sm rounded-0 dn" id="txtVID" name="VID">
<input type="text" class="form-control form-control-sm rounded-0" id="txtVCode" name="VCode" readonly>
</div>
<label class="col-sm-2 col-form-label">Date</label>
<div class="col-sm-4">
<input type="text" class="form-control form-control-sm rounded-0 CustomDate" id="txtVdate" name="Vdate" maxlength="10" data-date-format="DD/MM/YYYY">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2 col-form-label">Expense Type</label>
<div class="col-sm-4">
<select class="form-control form-control-sm rounded-0 select2" id="ddlExpenseTypeID" name="ExpenseTypeID">
<option value="">Select Expense Type </option>
</select>
</div>
<label class="col-sm-2 col-form-label">Note</label>
<div class="col-sm-4">
<input type="text" class="form-control form-control-sm rounded-0 " id="txtNote" name="Note">
</div>
</div>
<div class="form-group row">
<div class="col-sm-12">
@*<button type="reset" class="btn btn-sm btn-danger waves-effect waves-light pull-right dn"><i class="fa fa-times"></i> CANCEL</button>*@
<button id="btnsave" type="submit" class="btn btn-sm btn-success waves-effect waves-light pull-right "><i class="fa fa-check-square-o"></i> SAVE</button>
</div>
</div>
</form>
<div class="card">
<div class="card-header text-uppercase">Employee List</div>
<div class="card-body">
<div class="row">
<div class="col-md-12">
<table class="table table-bordered" id="tbl_AdminExp">
<thead>
<tr>
<th>
Sr #
</th>
<th>
Employee Code
</th>
<th>
Employee Name
</th>
<th>
Amount
</th>
</tr>
</thead>
<tbody id="tbl_tbody_AdminExp">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!--End Row-->
<script>
$(document).ready(function () {
var urlloc = GetqueryStr("VID");
if (urlloc) {
LoadGetRight("Accounts", "AdminExpenseVoucherList", "Update");
$(".divtitle").html("Edit Admin Expense Voucher");
EditLoadAdminExp(urlloc);
}
else {
LoadGetRight("Accounts", "AdminExpenseVoucherList", "Insert");
LoadVCode("#txtVCode", "AdminExpenseHeader", "Application Code Error");
LoadddlSetup("#ddlExpenseTypeID", "Expense Type", "ExpenseTypes-list");
EditLoadAdminExp(0);
$(".divtitle").html(" Add Admin Expense Voucher");
}
SaveAdminExp();
});
function addAdminExphtml(SRno,VID, AdminExpenseHeaderID, EmployeeID, EmployeeCode, EmployeeName, Amount) {
var myhtml = ' <tr><td ><small class="text-muted">' + SRno + '</small></td><td ><small class="text-muted CL_VID dn">' + VID + '</small><small class="text-muted CL_AdminExpenseHeaderID dn">' + AdminExpenseHeaderID + '</small><small class="text-muted CL_EmployeeID dn">' + EmployeeID + '</small><small class="text-muted">' + EmployeeCode + '</small></td>' +
' <td ><small class="text-muted">' + EmployeeName + '</small></td>' +
' <td ><input type="number" class="form-control form-control-sm rounded-0 CL_Amount " id="txtAmount" name="Amount" value="' + Amount +'"></td>' +
' </tr>';
$("#tbl_tbody_AdminExp").append(myhtml);
}
</script>
<script>
function EditLoadAdminExp(VID) {
$.ajax({
contentType: 'application/json; charset=utf-8',
dataType: 'JSON',
url: mybesturl + 'Accounts/LoadAddminExpByID?VID=' + VID,
type: 'post',
data: {},
success: function (result) {
if (result != null) {
if (result.MessageType == true) {
var lstbyid = result.Reslst;
console.log(result);
if (VID > 0) {
$('#txtVID').val(lstbyid.VID);
$('#txtVCode').val(lstbyid.VCode);
$('#txtVdate').val(lstbyid.VdateStr );
LoadddlSetupSelected("#ddlExpenseTypeID", "Expense Type", "ExpenseTypes-list", lstbyid.ExpenseTypeID);
$('#txtNote').val(lstbyid.Note);
}
if (result.Dlist.length > 0) {
$("#tbl_tbody_AdminExp").html("");
var mcount = 1;
$.each(result.Dlist, function (index, obj) {
addAdminExphtml(mcount,obj.VID, obj.AdminExpenseHeaderID, obj.EmployeeID, obj.EmployeeCode, obj.EmployeeName, obj.Amount);
mcount += mcount;
});
}
else {
$("#tbl_tbody_AdminExp").html("");
}
} else {
// console.log(result);
if (result.MessageCode === "02") {
toasterall('Error', result.Message, 'error');
}
else {
// console.log(result);
if (result.MessageCode === "03") {
toasterall('Error', result.Message, 'error');
}
else {
toasterall('Error', result.Message, 'error');
}
}
}
}
},
failure: function (result) {
toasterall('Error', result, 'error');
},
error: function (xhr, textStatus, errorThrown) {
if (xhr.status === 401) {
window.location.href = myPathLogin;
}
}
});
}
function SaveAdminExp() {
var validator = $("#frmAddAdminExpenseVoucher").validate({
rules: {
VCode: "required",
Vdate: "required",
ExpenseTypeID: "required",
Note: "required"
},
messages: {
VCode: "required",
Vdate: "required",
ExpenseTypeID: "required",
Note: "required"
},
submitHandler: function () {
var $TAdminExpItem = $('#tbl_AdminExp > tbody > tr');
var LAdminExpItem = [];
var chkDet = 0;
$.each($TAdminExpItem, function (index, value) {
var amtde = $(value).find(".CL_Amount").val() == "" ? 0 : $(value).find(".CL_Amount").val();
if (amtde > 0) {
chkDet += 1;
}
var BAdminExpItem = new Object();
BAdminExpItem["VID"] = $(value).find(".CL_VID").text();
BAdminExpItem["AdminExpenseHeaderID"] = $(value).find(".CL_AdminExpenseHeaderID").text();
BAdminExpItem["EmployeeID"] = $(value).find(".CL_EmployeeID").text();
BAdminExpItem["Amount"] = $(value).find(".CL_Amount").val() == "" ? 0 : $(value).find(".CL_Amount").val();
LAdminExpItem.push(BAdminExpItem);
});
var para = {
VID: $('#txtVID').val() == "" ? 0 : $('#txtVID').val(),
VCODE: $('#txtVCode').val(),
Vdate: $('#txtVdate').val(),
ExpenseTypeID: $('#ddlExpenseTypeID').val() == "" ? 0 : $('#ddlExpenseTypeID').val(),
Note: $('#txtNote').val(),
AdminExpenseDetail: LAdminExpItem
};
if (chkDet == 0) {
toasterall('Error', 'Please Add Amount atleast 1 Employee', 'error');
return false;
}
$('#btnsave').prop('disabled', true);
try {
$.ajax({
type: 'POST',
url: mybesturl + 'Accounts/AddAdminExpenseVoucher',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(para),
success: function (result) {
if (result != null) {
if (result.MessageType == true) {
toasterall('Error', result.Message, 'success');
RedirectPageURL('Accounts/AdminExpenseVoucherList');
} else {
if (result.MessageCode === "03") {
toasterall('Error', result.Message, 'error');
}
else {
toasterall('Error', result.Message, 'error');
}
}
}
},
failure: function (result) {
toasterall('Error', result, 'error');
},
error: function (xhr, textStatus, errorThrown) {
toasterall('Error', errorThrown, 'error');
if (xhr.status === 500) {
RedirectPageURL('Login');
}
}
});
} catch (err) {
toasterall('Error', err.message, 'error');
}
finally {
$('#btnsave').removeAttr("disabled");
}
}
});
}
</script>
Entity Framework core Database First Approach .net 6
setp 1 ::::::
Scaffold-DbContext "Data Source=.;Initial Catalog=CMS;Persist Security Info=True;User ID=swera;Password=1122333;" Microsoft.EntityFrameworkCore.SqlServer -Context NWContext -OutputDir Models/DB -ContextDir Models/Context -Tables Account
setp 2 ::::::
Update existing models
Scaffold-DbContext "Data Source=.;Initial Catalog=CMS;Persist Security Info=True;User ID=swera;Password=1122333;" -Provider Microsoft.EntityFrameworkCore.SqlServer -Context NWContext -OutputDir Models/DB -ContextDir Models/Context -Tables Aaa,Account -Force
setp 3 :::::: Add class CMSContextExt ::::::
public partial class CMSContext : DbContext
{
public virtual DbSet<MySPModel> MySP { get; set; } // your new DbQuery
}
Sep 4 :::::: Call Proc
var mLoginUser = new SqlParameter("User", "admin");
var mLoginPassword = new SqlParameter("Password", "admin");
var empRecord = _logCMS.SpGetbyLogin.FromSqlRaw("EXEC dbo.SpGetbyLogin @User, @Password", new SqlParameter[] { mLoginUser, mLoginPassword }).ToList();
EF Core Power Tool With Visual Studio
To Download from Click here
Step 2
Enable or Disable all triggers in a Sql server
DECLARE @TriggerTableName NVARCHAR(500)
DECLARE DisableTriggerCursor CURSOR
FOR
(
SELECT NAME AS TableName
FROM sysobjects
WHERE id IN (
SELECT parent_obj
FROM sysobjects
WHERE xtype = 'tr'
)
)
OPEN DisableTriggerCursor
FETCH NEXT
FROM DisableTriggerCursor
INTO @TriggerTableName
WHILE @@fetch_status = 0
BEGIN
SET @DisableTriggerCommand = N'ALTER TABLE ' + @TriggerTableName + ' ENABLE TRIGGER ALL'
PRINT 'Print ' + @DisableTriggerCommand + CHAR(13)
EXECUTE sp_executesql @DisableTriggerCommand
FETCH NEXT
FROM DisableTriggerCursor
INTO @TriggerTableName
END
CLOSE DisableTriggerCursor
DEALLOCATE DisableTriggerCursor
How AdminLTE-3 template integrate to angular 9
npm install -g @angular/cli ng new my-app ng new my-app ? Would you like to add Angular routing? Yes ? Which stylesheet format would you like to use? SCSS [ http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax ] ng serve
Step 2
From the Admin LTE file copy the dist and plugins folder to assets folder
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mltbapp</title>
<base href="/">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- Bootstrap 3.3.7 -->
<linkrel="stylesheet" href="assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Font Awesome -->
<link rel="stylesheet" href="assets/plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- Tempusdominus Bbootstrap 4 -->
<link rel="stylesheet" href="assets/plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
<!-- iCheck -->
<link rel="stylesheet" href="assets/plugins/icheck-bootstrap/icheck-bootstrap.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="assets/dist/css/adminlte.min.css">
<!-- overlayScrollbars -->
<link rel="stylesheet" href="assets/plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
<!-- Daterange picker -->
<link rel="stylesheet" href="assets/plugins/daterangepicker/daterangepicker.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed">
<div class="wrapper">
<app-root></app-root>
</div>
<!-- jQuery -->
<script src="assets/plugins/jquery/jquery.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="assets/plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
$.widget.bridge('uibutton', $.ui.button)
</script>
<!-- Bootstrap 4 -->
<script src="assets/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- ChartJS -->
<script src="assets/plugins/chart.js/Chart.min.js"></script>
<!-- Sparkline -->
<script src="assets/plugins/sparklines/sparkline.js"></script>
<!-- daterangepicker -->
<script src="assets/plugins/moment/moment.min.js"></script>
<script src="assets/plugins/daterangepicker/daterangepicker.js"></script>
<!-- Tempusdominus Bootstrap 4 -->
<script src="assets/plugins/tempusdominus-bootstrap-4/js/tempusdominus-bootstrap-4.min.js"></script>
<!-- overlayScrollbars -->
<script src="assets/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js"></script>
<!-- AdminLTE App -->
<script src="assets/dist/js/adminlte.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="assets/dist/js/demo.js"></script>
</body>
</html>
ng g c appheader
ng g c appmenu
ng g c appfooter
ng g c appsetting
////app.component.html
<app-appheader></app-appheader>
<app-appmenu></app-appmenu>
<router-outlet></router-outlet>
<app-appfooter></app-appfooter>
<app-appsetting></app-appsetting>
Past code in respective component
if you want to code add comment
How fill Drop down list in angular 9 with api Asp.net pi
CREATE TABLE [dbo].[tblSkills]( [SkillID] [int] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL, [Title] [varchar](50) NULL, [isacrtive] [bit] NULL, PRIMARY KEY CLUSTERED ( [SkillID] 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 SET ANSI_PADDING OFF GO SET IDENTITY_INSERT [dbo].[tblSkills] ON INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (1, N'Visual Foxpro', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (2, N'C#', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (3, N'VB.NET', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (4, N'Delphi', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (5, N'Java', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (6, N'Power Builder', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (7, N'COBOL', NULL) INSERT [dbo].[tblSkills] ([SkillID], [Title], [isacrtive]) VALUES (8, N'Python', NULL) SET IDENTITY_INSERT [dbo].[tblSkills] OFF
Scaffold-DbContext "Server=.;Database=MbkTest;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Tables tblSkills -Force
TblSkillsController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using CurdAPP2.Models;
namespace CurdAPP2.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class TblSkillsController : ControllerBase
{
private readonly MbkTestContext _context;
public TblSkillsController(MbkTestContext context)
{
_context = context;
}
// GET: api/TblSkills
[HttpGet]
public async Task<ActionResult<IEnumerable<TblSkills>>> GetTblSkills()
{
return await _context.TblSkills.ToListAsync();
}
// GET: api/TblSkills/5
[HttpGet("{id}")]
public async Task<ActionResult<TblSkills>> GetTblSkills(int id)
{
var tblSkills = await _context.TblSkills.FindAsync(id);
if (tblSkills == null)
{
return NotFound();
}
return tblSkills;
}
// PUT: api/TblSkills/5
[HttpPut("{id}")]
public async Task<IActionResult> PutTblSkills(int id, TblSkills tblSkills)
{
if (id != tblSkills.SkillId)
{
return BadRequest();
}
_context.Entry(tblSkills).State = EntityState.Modified;
try
{
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!TblSkillsExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return NoContent();
}
// POST: api/TblSkills
[HttpPost]
public async Task<ActionResult<TblSkills>> PostTblSkills(TblSkills tblSkills)
{
_context.TblSkills.Add(tblSkills);
await _context.SaveChangesAsync();
return CreatedAtAction("GetTblSkills", new { id = tblSkills.SkillId }, tblSkills);
}
// DELETE: api/TblSkills/5
[HttpDelete("{id}")]
public async Task<ActionResult<TblSkills>> DeleteTblSkills(int id)
{
var tblSkills = await _context.TblSkills.FindAsync(id);
if (tblSkills == null)
{
return NotFound();
}
_context.TblSkills.Remove(tblSkills);
await _context.SaveChangesAsync();
return tblSkills;
}
private bool TblSkillsExists(int id)
{
return _context.TblSkills.Any(e => e.SkillId == id);
}
}
}
Angular
skillsM.ts
blog-post.service.tsexport class skillsM { skillId?: number; title: string; isacrtive?: number; }
getskills(): Observable<skillsM[]> {
return this.http.get<skillsM[]>(this.myAppUrl + 'api/TblSkills/')
.pipe(
retry(1),
catchError(this.errorHandler)
);
}
public skillsMs: Observable<skillsM[]>;
this.skillsMs = this.blogPostService.getskills();
<select class="form-control" [formControl]="skillId">
<option value="0">--Select--</option>
<option *ngFor="let blogPost of (skillsMs | async)"
value={{blogPost.skillId}}>
{{blogPost.title}}
</option>
</select>