using OrderDemoMODEL;
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrderDemoREPOSITORY
{
public class MST_OrderNoRepository : MST_OrderNo_IRepository
{
private OrderDemoEntities Context;
public MST_OrderNoRepository(OrderDemoEntities _Context)
{
this.Context = _Context;
}
public string getOrderNo()
{
return Context.Get_Order_no().First().ToString();
}
public List<Get_Recored_Result> getOrderRecored()
{
return Context.Get_Recored().ToList();
}
public int InsertUpdate(String Str, string Detal, out int ReturnValue)
{
ReturnValue = 0;
var OutParam = new ObjectParameter("ReturnValue", typeof(int));
Context.insertupdate(Str, Detal, OutParam);
return Convert.ToInt16(OutParam.Value);
}
private bool disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
Context.Dispose();
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}
using System;
using System.Collections.Generic;
using System.Data.Entity.Core.Objects;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrderDemoREPOSITORY
{
public class MST_OrderNoRepository : MST_OrderNo_IRepository
{
private OrderDemoEntities Context;
public MST_OrderNoRepository(OrderDemoEntities _Context)
{
this.Context = _Context;
}
public string getOrderNo()
{
return Context.Get_Order_no().First().ToString();
}
public List<Get_Recored_Result> getOrderRecored()
{
return Context.Get_Recored().ToList();
}
public int InsertUpdate(String Str, string Detal, out int ReturnValue)
{
ReturnValue = 0;
var OutParam = new ObjectParameter("ReturnValue", typeof(int));
Context.insertupdate(Str, Detal, OutParam);
return Convert.ToInt16(OutParam.Value);
}
private bool disposed = false;
protected virtual void Dispose(bool disposing)
{
if (!this.disposed)
{
if (disposing)
{
Context.Dispose();
}
}
this.disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}
*****************************************************************************
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
@Styles.Render("~/bundles/Content/css")
@Scripts.Render("~/bundles/Content/Js")
<style>
.error {
border: 1px solid red;
}
.hide {
visibility: hidden;
}
</style>
</head>
<body>
<div class="Container panel-group">
<div class="row panel panel-default" style="margin-top: 10px;">
<div class="col-sm-3 panel-body">
<label>Order No :</label><input id="OrderNo" type="text" class="Required" value="@ViewBag.OrderNo" />
</div>
<div class="col-sm-3 panel-body">
<label>Order Date :</label>
<input type="text" id="datepicker" class="Required">
</div>
<div class="col-sm-3 panel-body">
<label>Party Name :</label><input id="Orderparty" type="text" class="Required" />
</div>
<div class="col-sm-3 panel-body">
<input type="button" id="SaveID" value="Save" />
<input type="button" id="ClearID" value="Clear" />
</div>
</div>
<table id="example" class="display nowrap dataTable dtr-inline" cellspacing="0" width="100%" role="grid" aria-describedby="example_info" style="width: 100%;">
<thead>
<tr role="row">
<td>OrderDetail ID</td>
<td>Order ID</td>
<td>OrderItemNo</td>
<td>Order OrderNo</td>
<td>Order Quntity</td>
<td style="display: none">Orderdate</td>
<td style="display: none">TotalAmt</td>
</tr>
</thead>
<tfoot>
<tr>
<td>OrderDetail ID</td>
<td>Order ID</td>
<td>OrderItemNo</td>
<td>Order Amt</td>
<td>Order Quntity</td>
<td style="display: none">Orderdate</td>
<td style="display: none">TotalAmt</td>
</tr>
</tfoot>
</table>
</div>
</body>
</html>
<script>
$(function () {
$("#datepicker").datepicker().datepicker("setDate", new Date());
});
</script>
<script type="text/javascript">
$("#SaveID").click(function () {
var Flag = true;
$(".Required").each(function () {
if ($(this).val().length === 0) {
$(this).addClass('error');
Flag = false;
}
});
if (Flag) {
debugger
var StrXml = { "OrderNo": $("#OrderNo").val(), "OrderID": 0, "OrderDate": $("#datepicker").val(), "OrderQuntity": "1", "OrderAmt": "1400" }
var StrDetail = { "OrderDetailID": 0, "OrderID": 0, "OrderAmt": "500", "OrderQuntity": "2", "OrderItemNo": $("#OrderNo").val() }
$.ajax({
type: "POST",
url: '@Url.Action("SetDate", "Home")',
data: JSON.stringify({ StrXml: StrXml, StrDetail: StrDetail, Odate: $("#datepicker").val() }),
contentType: 'application/json; charset=utf-8',
success: function (Result) {
//alert(Result);
}
});
}
});
$(".Required").blur(function () {
if ($(this).val().length != 0) {
$(this).removeClass("error")
}
});
$(document).ready(function () {
Display();
});
function Display() {
var oTable = $('#example').dataTable({
responsive: true,
"processing": true,
"serverSide": true,
"bSort": false,
"sAjaxSource": "@Url.Action("getData", "Home")",
"iDisplayLength": 10,
"aLengthMenu": [5, 10, 50, 100, 200],
"bDestroy": true,
"bInfo": true,
"sEmptyTable": "Loading data from server",
"searching": false,
"bLengthChange": true,
"bFilter": true,
"bPaginate": true,
"autoWidth": true,
"sScrollY": "400px",
"sScrollX": "100px",
"bScrollCollapse": true,
"sPaginationType": "simple_numbers",
"paging": true, "fnServerData": function (sSource, aoData, fnCallback) {
aoData.push(
{ "name": "SearchCritearea", "value": "" });
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
}).done(function (json) {
//$(".dataTables_scrollFootInner").find("#Request_Cr").html(json.TotalRequestCr);
//$(".dataTables_scrollFootInner").find("#Request_Cnt").html(json.TotalRequestCnt);;
//$('#loading-indicator').hide();
});
},
"fnInitComplete": function (oSettings, json) {
//$(".dataTables_scrollFootInner").find("#Request_Cr").html(json.TotalRequestCr);
//$(".dataTables_scrollFootInner").find("#Request_Cnt").html(json.TotalRequestCnt);;
},
"columns": [
{
"sClass": " OrderDetailID",
"render": function (data, type, row, meta) {
return row[0];
}
},
{
"sClass": " OrderID",
"render": function (data, type, row, meta) {
return row[1];
}
},
{
"sClass": " OrderItemNo",
"render": function (data, type, row, meta) {
return row[2];
}
},
{
"sClass": " OrderNo",
"render": function (data, type, row, meta) {
return row[3];
}
},
{
"sClass": "Center OrderQuntity",
"render": function (data, type, row, meta) {
return row[4];
}
},
{
"sClass": "hide OrderQuntity",
"render": function (data, type, row, meta) {
return row[5];
}
},
{
"sClass": "hide OrderQuntity",
"render": function (data, type, row, meta) {
return row[6];
}
}
]
});
}
</script>
*********************************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Optimization;
namespace OrderDemo.App_Start
{
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new StyleBundle("~/bundles/Content/css").Include("~/Content/css/bootstrap.css", "~/Content/css/jquery-ui.css", "~/Content/css/jquery.dataTables.min.css"));
bundles.Add(new ScriptBundle("~/bundles/Content/Js").Include("~/Content/js/jquery-3.2.1.js", "~/Content/js/bootstrap.js", "~/Content/js/jquery-ui.js", "~/Content/js/jquery.dataTables.min.js"));
BundleTable.EnableOptimizations = true;
}
}
}
*********************************************************************************
using OrderDemoMODEL;
using OrderDemoREPOSITORY;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml.Serialization;
namespace OrderDemo.Controllers
{
public class HomeController : Controller
{
MST_OrderNo_IRepository _MST_OrderNo_IRepository = new MST_OrderNoRepository(new OrderDemoEntities());
//
// GET: /Home/
public ActionResult Index()
{
ViewBag.OrderNo = _MST_OrderNo_IRepository.getOrderNo();
return View("Index");
}
[HttpPost]
public JsonResult SetDate(TRN_ORDER_MASTER StrXml, TRN_ORDER_DETAILS StrDetail, string Odate)
{
var SuccessFlag = 0;
string xml = "<TRN_ORDER_MASTER><OrderID>" + StrXml.OrderID + "</OrderID><OrderNo>" + StrXml.OrderNo + "</OrderNo><OrderDate>" + StrXml.OrderDate + "</OrderDate><OrderQuntity>" + StrXml.OrderQuntity + "</OrderQuntity><OrderAmt>" + StrXml.OrderAmt + "</OrderAmt></TRN_ORDER_MASTER>";
string xmlDetail = "<TRN_ORDER_DETAILS><OrderDetailID>" + StrDetail.OrderDetailID + "</OrderDetailID><OrderID>" + StrDetail.OrderID + "</OrderID><OrderQuntity>" + StrDetail.OrderQuntity + "</OrderQuntity><OrderAmt>" + StrDetail.OrderAmt + "</OrderAmt><OrderItemNo>" + StrDetail .OrderItemNo+ "</OrderItemNo></TRN_ORDER_DETAILS>";
SuccessFlag = _MST_OrderNo_IRepository.InsertUpdate(xml, xmlDetail, out SuccessFlag);
return Json(SuccessFlag, JsonRequestBehavior.AllowGet);
}
public static string Serialize(object dataToSerialize)
{
if (dataToSerialize == null) return null;
using (StringWriter stringwriter = new System.IO.StringWriter())
{
var serializer = new XmlSerializer(dataToSerialize.GetType());
serializer.Serialize(stringwriter, dataToSerialize);
return stringwriter.ToString();
}
}
public static T Deserialize<T>(string xmlText)
{
if (String.IsNullOrWhiteSpace(xmlText)) return default(T);
using (StringReader stringReader = new System.IO.StringReader(xmlText))
{
var serializer = new XmlSerializer(typeof(T));
return (T)serializer.Deserialize(stringReader);
}
}
[HttpPost]
public JsonResult getData(JQueryDataTable aoData)
{
List<Get_Recored_Result> _List = _MST_OrderNo_IRepository.getOrderRecored();
var Result = from c in _List
select new[]
{
c.OrderDetailID.ToString(),c.OrderID.ToString(),c.OrderItemNo.ToString(),c.OrderNo.ToString(),c.OrderQuntity.ToString(),c.TotalAMt.ToString(),c.OrderDate.ToString()
};
return Json(new
{
aaData = Result
}, JsonRequestBehavior.AllowGet);
}
}
}
********************************************************************************
0 Comments