$(document).ready(function () {
$("#btnAnimation").click(function () {
});
$("#btnSaved").click(function () {
var Datas = [];
var rowCount = document.getElementById("CustmApnd").rows.length;
if (rowCount == 1) {
alert("There is no items");
} else {
for (var i = 1; i < rowCount; i++) {
Datas[i] = new Object();
Datas[i].Fname = document.getElementById("CustmApnd").rows[i].cells[0].childNodes[0].value;
Datas[i].Lname = document.getElementById("CustmApnd").rows[i].cells[1].childNodes[0].value;
}
}
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Master.aspx/SaveDetails",
data: "{'Details':'" + JSON.stringify(Datas) + "'}",
dataType: "json",
success: function (data) {
alert(data.d);
$('#JtableDiv').jtable('load');
}
});
});
$("#BtnAddMor").click(function () {
$("#CustmApnd").append('<tr><td><input type="text" placeholder="First name" class="textox" /></td><td><input type="text" placeholder="Last name" class="textox" /></td><td><input value="Remove" type="button" onclick="($(this)).parent().parent().remove()" class="button" /></td></tr>');
});
$("#BtnSave").click(function () {
var fname = $("#Fname").val();
var Lname = $("#Lname").val();
$.ajax({
type: "POST",
url: "Master.aspx/MyMethod",
data: "{ fname: '" + fname + "',Lname: '" + Lname + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d == "T") {
alert(fname + ' ' + Lname + 'Saved Succsessfully');
}
else {
alert(fname + ' ' + Lname + ' Not Saved Succsessfully');
}
},
Error: function (x, e) {
alert("Try after some time");
}
});
});
});
$(document).ready(function () {
$("#Jtab").hide();
$("#btnGo").click(function () {
$("#Jtab").show();
});
$('#JtableDiv').jtable({
title: 'Details',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'Name ASC', //Set default sorting
actions: {
listAction: '/Master.aspx/GetAll'
},
fields: {
Lname: {
title: 'Lname',
width: '15%'
},
Fname: {
title: 'Fname',
width: '15%'
}
}
});
//Load student list from server
$('#JtableDiv').jtable('load');
});
$("#btnAnimation").click(function () {
});
$("#btnSaved").click(function () {
var Datas = [];
var rowCount = document.getElementById("CustmApnd").rows.length;
if (rowCount == 1) {
alert("There is no items");
} else {
for (var i = 1; i < rowCount; i++) {
Datas[i] = new Object();
Datas[i].Fname = document.getElementById("CustmApnd").rows[i].cells[0].childNodes[0].value;
Datas[i].Lname = document.getElementById("CustmApnd").rows[i].cells[1].childNodes[0].value;
}
}
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Master.aspx/SaveDetails",
data: "{'Details':'" + JSON.stringify(Datas) + "'}",
dataType: "json",
success: function (data) {
alert(data.d);
$('#JtableDiv').jtable('load');
}
});
});
$("#BtnAddMor").click(function () {
$("#CustmApnd").append('<tr><td><input type="text" placeholder="First name" class="textox" /></td><td><input type="text" placeholder="Last name" class="textox" /></td><td><input value="Remove" type="button" onclick="($(this)).parent().parent().remove()" class="button" /></td></tr>');
});
$("#BtnSave").click(function () {
var fname = $("#Fname").val();
var Lname = $("#Lname").val();
$.ajax({
type: "POST",
url: "Master.aspx/MyMethod",
data: "{ fname: '" + fname + "',Lname: '" + Lname + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
if (msg.d == "T") {
alert(fname + ' ' + Lname + 'Saved Succsessfully');
}
else {
alert(fname + ' ' + Lname + ' Not Saved Succsessfully');
}
},
Error: function (x, e) {
alert("Try after some time");
}
});
});
});
$(document).ready(function () {
$("#Jtab").hide();
$("#btnGo").click(function () {
$("#Jtab").show();
});
$('#JtableDiv').jtable({
title: 'Details',
paging: true, //Enable paging
pageSize: 10, //Set page size (default: 10)
sorting: true, //Enable sorting
defaultSorting: 'Name ASC', //Set default sorting
actions: {
listAction: '/Master.aspx/GetAll'
},
fields: {
Lname: {
title: 'Lname',
width: '15%'
},
Fname: {
title: 'Fname',
width: '15%'
}
}
});
//Load student list from server
$('#JtableDiv').jtable('load');
});
-----------------------------------------------------------------------------
AUTOCOMPLETE
-----------------------------------------------------------------------------
$("#txtId").autocomplete({
source: function (request, response) {
$.ajax({
url: '<%= ResolveUrl("../Cashier/AdvancedPayments.aspx/Filter") %>',
data: "{ 'patientID':'" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) {
return data;
},
success: function (data) {
response(data.d);
}
});
$.ajax({
url: '<%= ResolveUrl("../Cashier/AdvancedPayments.aspx/GetInpatient") %>',
data: "{ 'patientID':'" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) {
return data;
},
success: function (data) {
response(data.d);
$("#Details").empty();
$(".txtIp").empty();
$(".txtIp").val(data.d);
}
});
}
});
source: function (request, response) {
$.ajax({
url: '<%= ResolveUrl("../Cashier/AdvancedPayments.aspx/Filter") %>',
data: "{ 'patientID':'" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) {
return data;
},
success: function (data) {
response(data.d);
}
});
$.ajax({
url: '<%= ResolveUrl("../Cashier/AdvancedPayments.aspx/GetInpatient") %>',
data: "{ 'patientID':'" + request.term + "' }",
dataType: "json",
type: "POST",
contentType: "application/json; charset=utf-8",
dataFilter: function (data) {
return data;
},
success: function (data) {
response(data.d);
$("#Details").empty();
$(".txtIp").empty();
$(".txtIp").val(data.d);
}
});
}
});
JTABLE
<script type="text/javascript">
$(document).ready(function () {
$('#SearchJtable').hide();
$('#SearchJtable').jtable({
title: 'ADVANCED PAYMENTS DETAILS',
paging: true,
pageSize: 5,
selecting: true,
actions: {
listAction: '../Cashier/AdvancedPayments.aspx/AdvancedPaymentHistory'
},
fields: {
// patientId: {
// title: 'IP ID ',
// key: true,
// create: false,
// edit: false,
// width: '15%',
// list: false
// },
BillNo: {
title: 'PAYMENT ID',
width: '15%'
},
Date: {
title: 'DATE',
width: '15%',
create: false,
edit: false
},
Time: {
title: 'TIME',
width: '15%'
},
X: {
title: 'GO TO BILL',
selecting: true,
display: function (Datas) {
var $img1 = null;
$img1 = $('<img src="../Scripts/jtable/themes/bill.png" height="30" width="35" />');
$img1.click(function () {
$(".ErrorMsg").slideDown("5000");
$(".BackgroundPopup").show();
$("#btnOk").click(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: '<%=ResolveUrl("../Cashier/AdvancedPayments.aspx/GetBillDetails")%>',
data: "{'PaymentId':'" + Datas.record.BillNo + "','IpNo':'" + $(".txtIpNumber").val() + "'}",
dataType: "json",
success: function (data) {
var details = JSON.parse(data.d);
window.location = "BillSection.aspx?AdvancedPaymentId=" + Datas.record.BillNo + "&AdvancedBillno=" + details.IPBillNo + "&Option=" + 'AdvancedPayment' + "&Ipno=" + $(".txtIpNumber").val()
}
});
});
});
return $img1;
}
}
}
});
$(".txtIpNumber").change(function (e) {
var result = SearchValidation();
if (result == 1) {
e.preventDefault();
$('#SearchJtable').show();
$("#SearchJtable").jtable('load', {
id: $(".txtIpNumber").val()
});
} else {
e.preventDefault();
$('#SearchJtable').hide();
}
});
$(document).ready(function () {
$('#SearchJtable').hide();
$('#SearchJtable').jtable({
title: 'ADVANCED PAYMENTS DETAILS',
paging: true,
pageSize: 5,
selecting: true,
actions: {
listAction: '../Cashier/AdvancedPayments.aspx/AdvancedPaymentHistory'
},
fields: {
// patientId: {
// title: 'IP ID ',
// key: true,
// create: false,
// edit: false,
// width: '15%',
// list: false
// },
BillNo: {
title: 'PAYMENT ID',
width: '15%'
},
Date: {
title: 'DATE',
width: '15%',
create: false,
edit: false
},
Time: {
title: 'TIME',
width: '15%'
},
X: {
title: 'GO TO BILL',
selecting: true,
display: function (Datas) {
var $img1 = null;
$img1 = $('<img src="../Scripts/jtable/themes/bill.png" height="30" width="35" />');
$img1.click(function () {
$(".ErrorMsg").slideDown("5000");
$(".BackgroundPopup").show();
$("#btnOk").click(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: '<%=ResolveUrl("../Cashier/AdvancedPayments.aspx/GetBillDetails")%>',
data: "{'PaymentId':'" + Datas.record.BillNo + "','IpNo':'" + $(".txtIpNumber").val() + "'}",
dataType: "json",
success: function (data) {
var details = JSON.parse(data.d);
window.location = "BillSection.aspx?AdvancedPaymentId=" + Datas.record.BillNo + "&AdvancedBillno=" + details.IPBillNo + "&Option=" + 'AdvancedPayment' + "&Ipno=" + $(".txtIpNumber").val()
}
});
});
});
return $img1;
}
}
}
});
$(".txtIpNumber").change(function (e) {
var result = SearchValidation();
if (result == 1) {
e.preventDefault();
$('#SearchJtable').show();
$("#SearchJtable").jtable('load', {
id: $(".txtIpNumber").val()
});
} else {
e.preventDefault();
$('#SearchJtable').hide();
}
});
CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Configuration;
using Hospital.core;
using System.IO;
using System.Text;
using Microsoft.ReportingServices;
using Microsoft.Reporting.WebForms;
using System.Web.Script.Serialization;
using System.IO.IsolatedStorage;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using Hospital.DataAcessLayer;
namespace HospitalManagmentSystem2014.Cashier
{
public partial class AdvancedPayments : System.Web.UI.Page
{
public static string CatogoryType;
public static string IpNumber;
public static string catogory;
public static string advancedLastBill;
public static Int32 patientNumber;
protected void Page_Load(object sender, EventArgs e)
{
}
#region Fill J_Table
[WebMethod(EnableSession = true)]
public static object AdvancedPaymentHistory(int jtStartIndex, int jtPageSize, string id)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
try
{
string BillNumber = string.Empty;
int idVal = Convert.ToInt32(id);
Int32 ChartCount = Convert.ToInt32(cManager.ListCount(idVal));
List<CasherAdvanced> ChartHistory = cManager.GetAllAdvancedPaymentHistory(jtStartIndex, jtPageSize, id);
return new { Result = "OK", Records = ChartHistory, TotalRecordCount = ChartCount };
}
catch (Exception ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
#endregion Fill J_Table
#region textbox Id Autocomplte
[WebMethod(EnableSession = true)]
public static List<string> Filter(string patientID)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<string> ChartHistory = new List<string>();
var serializer = new JavaScriptSerializer();
try
{
ChartHistory = cManager.FilterHistory(patientID);
}
catch (Exception)
{
}
return ChartHistory;
}
#endregion textbox Id Autocomplte
#region Get Ipno depend on Op
/// <summary>
/// depend on op,fetch ip from db
/// </summary>
/// <param name="patientID"></param>
/// <returns></returns>
[WebMethod(EnableSession = true)]
public static List<string> GetInpatient(string patientID)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<string> IP = new List<string>();
var serializer = new JavaScriptSerializer();
try
{
IP = cManager.GetInpatientId(patientID);
}
catch (Exception)
{
}
return IP;
}
#endregion
#region Fill DropDown
/// <summary>
/// Fill fee on dropdown depend on service selected
/// </summary>
/// <returns></returns>
[WebMethod(EnableSession = true)]
public static List<CasherAdvanced> BindDropdownService()
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<CasherAdvanced> ServiceObj = cManager.getService();
return ServiceObj;
}
#endregion
#region Item Saved To Advanced item table
[WebMethod]
public static string AdvancedPaymentItem(string paymentDetails)
{
string returnValue = string.Empty;
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<CasherAdvanced> PaymentObj = serializer.Deserialize<List<CasherAdvanced>>(paymentDetails);
int count = PaymentObj.Count;
AdvancedPayments x = new AdvancedPayments();
Boolean statusProducts = false;
CasherAdvanced pay = new CasherAdvanced();
string billno = x.SaveToAdvancedbill(PaymentObj);
for (int i = 1; i < count; i++)
{
statusProducts = cManager.AdvancedPaymentSections(billno, PaymentObj[i].service, PaymentObj[i].charge);
}
if (statusProducts == true)
{
returnValue = "Saved";
}
return returnValue;
}
#endregion Item Saved To Advanced item table
#region Get Service Amount
[WebMethod]
public static string GetServiceAmount(string service)
{
string amount = string.Empty;
try
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
amount = cManager.GetServiceAmount(service);
}
catch (Exception)
{
}
return amount;
}
#endregion Get Service Amount
#region Save to advanced bill
/// <summary>
/// 1. save item to bill
/// 2.return billno
/// 3.depend on this bill no save all item to item table
/// </summary>
/// <param name="PatientList"></param>
/// <returns></returns>
public string SaveToAdvancedbill(List<CasherAdvanced> PatientList)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
string Pid = Convert.ToString(PatientList[1].patientId);
patientNumber = Convert.ToInt32(Pid);
Session["ipNumber"] = patientNumber;
DateTime time = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
string billno = cManager.InsertAdvancedBillDetails(Convert.ToInt32(Pid));
Session["billno"] = billno;
return billno;
}
#endregion Save to advanced bill
[WebMethod(EnableSession = true)]
public static object GetBillDetails(string PaymentId, string IpNo)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
AdvancedPayments obj = new AdvancedPayments();
CasherAdvanced advanced = obj.IPBILLSECTION(PaymentId, IpNo);
return serializer.Serialize(advanced);
}
public CasherAdvanced IPBILLSECTION(string PaymentId, string IpNo)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
string billno = Convert.ToString(PaymentId);
List<CasherAdvanced> AdvancedPaymentList = cManager.GetBillData(billno);
decimal totalAmount = 0;
foreach (CasherAdvanced payment in AdvancedPaymentList)
{
decimal charges = Convert.ToDecimal(payment.charge);
totalAmount = totalAmount + charges;
}
string mainBillno = MainBill(IpNo, totalAmount);
Session["mainBillno"] = mainBillno;
foreach (CasherAdvanced payment in AdvancedPaymentList)
{
string service = Convert.ToString(payment.service);
string charge = Convert.ToString(payment.charge);
string batch = "NA";
string quantity = "0";
cManager.MainBillItem(mainBillno, service, charge, batch, quantity);
}
CasherAdvanced obj = new CasherAdvanced();
obj.IPBillNo = Convert.ToString(Session["mainBillno"]);
return obj;
}
public string MainBill(string ip, decimal totalAmount)
{
Int32 isCredit = 0;
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
DateTime time = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
string Mainbillno = cManager.MainBillDetails(ip, HttpContext.Current.Session["userId"].ToString(), totalAmount, isCredit);
return Mainbillno;
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Configuration;
using Hospital.core;
using System.IO;
using System.Text;
using Microsoft.ReportingServices;
using Microsoft.Reporting.WebForms;
using System.Web.Script.Serialization;
using System.IO.IsolatedStorage;
using System.Data;
using System.Data.SqlClient;
using System.Threading;
using Hospital.DataAcessLayer;
namespace HospitalManagmentSystem2014.Cashier
{
public partial class AdvancedPayments : System.Web.UI.Page
{
public static string CatogoryType;
public static string IpNumber;
public static string catogory;
public static string advancedLastBill;
public static Int32 patientNumber;
protected void Page_Load(object sender, EventArgs e)
{
}
#region Fill J_Table
[WebMethod(EnableSession = true)]
public static object AdvancedPaymentHistory(int jtStartIndex, int jtPageSize, string id)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
try
{
string BillNumber = string.Empty;
int idVal = Convert.ToInt32(id);
Int32 ChartCount = Convert.ToInt32(cManager.ListCount(idVal));
List<CasherAdvanced> ChartHistory = cManager.GetAllAdvancedPaymentHistory(jtStartIndex, jtPageSize, id);
return new { Result = "OK", Records = ChartHistory, TotalRecordCount = ChartCount };
}
catch (Exception ex)
{
return new { Result = "ERROR", Message = ex.Message };
}
}
#endregion Fill J_Table
#region textbox Id Autocomplte
[WebMethod(EnableSession = true)]
public static List<string> Filter(string patientID)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<string> ChartHistory = new List<string>();
var serializer = new JavaScriptSerializer();
try
{
ChartHistory = cManager.FilterHistory(patientID);
}
catch (Exception)
{
}
return ChartHistory;
}
#endregion textbox Id Autocomplte
#region Get Ipno depend on Op
/// <summary>
/// depend on op,fetch ip from db
/// </summary>
/// <param name="patientID"></param>
/// <returns></returns>
[WebMethod(EnableSession = true)]
public static List<string> GetInpatient(string patientID)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<string> IP = new List<string>();
var serializer = new JavaScriptSerializer();
try
{
IP = cManager.GetInpatientId(patientID);
}
catch (Exception)
{
}
return IP;
}
#endregion
#region Fill DropDown
/// <summary>
/// Fill fee on dropdown depend on service selected
/// </summary>
/// <returns></returns>
[WebMethod(EnableSession = true)]
public static List<CasherAdvanced> BindDropdownService()
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
List<CasherAdvanced> ServiceObj = cManager.getService();
return ServiceObj;
}
#endregion
#region Item Saved To Advanced item table
[WebMethod]
public static string AdvancedPaymentItem(string paymentDetails)
{
string returnValue = string.Empty;
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
JavaScriptSerializer serializer = new JavaScriptSerializer();
List<CasherAdvanced> PaymentObj = serializer.Deserialize<List<CasherAdvanced>>(paymentDetails);
int count = PaymentObj.Count;
AdvancedPayments x = new AdvancedPayments();
Boolean statusProducts = false;
CasherAdvanced pay = new CasherAdvanced();
string billno = x.SaveToAdvancedbill(PaymentObj);
for (int i = 1; i < count; i++)
{
statusProducts = cManager.AdvancedPaymentSections(billno, PaymentObj[i].service, PaymentObj[i].charge);
}
if (statusProducts == true)
{
returnValue = "Saved";
}
return returnValue;
}
#endregion Item Saved To Advanced item table
#region Get Service Amount
[WebMethod]
public static string GetServiceAmount(string service)
{
string amount = string.Empty;
try
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
amount = cManager.GetServiceAmount(service);
}
catch (Exception)
{
}
return amount;
}
#endregion Get Service Amount
#region Save to advanced bill
/// <summary>
/// 1. save item to bill
/// 2.return billno
/// 3.depend on this bill no save all item to item table
/// </summary>
/// <param name="PatientList"></param>
/// <returns></returns>
public string SaveToAdvancedbill(List<CasherAdvanced> PatientList)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
string Pid = Convert.ToString(PatientList[1].patientId);
patientNumber = Convert.ToInt32(Pid);
Session["ipNumber"] = patientNumber;
DateTime time = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
string billno = cManager.InsertAdvancedBillDetails(Convert.ToInt32(Pid));
Session["billno"] = billno;
return billno;
}
#endregion Save to advanced bill
[WebMethod(EnableSession = true)]
public static object GetBillDetails(string PaymentId, string IpNo)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
AdvancedPayments obj = new AdvancedPayments();
CasherAdvanced advanced = obj.IPBILLSECTION(PaymentId, IpNo);
return serializer.Serialize(advanced);
}
public CasherAdvanced IPBILLSECTION(string PaymentId, string IpNo)
{
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
string billno = Convert.ToString(PaymentId);
List<CasherAdvanced> AdvancedPaymentList = cManager.GetBillData(billno);
decimal totalAmount = 0;
foreach (CasherAdvanced payment in AdvancedPaymentList)
{
decimal charges = Convert.ToDecimal(payment.charge);
totalAmount = totalAmount + charges;
}
string mainBillno = MainBill(IpNo, totalAmount);
Session["mainBillno"] = mainBillno;
foreach (CasherAdvanced payment in AdvancedPaymentList)
{
string service = Convert.ToString(payment.service);
string charge = Convert.ToString(payment.charge);
string batch = "NA";
string quantity = "0";
cManager.MainBillItem(mainBillno, service, charge, batch, quantity);
}
CasherAdvanced obj = new CasherAdvanced();
obj.IPBillNo = Convert.ToString(Session["mainBillno"]);
return obj;
}
public string MainBill(string ip, decimal totalAmount)
{
Int32 isCredit = 0;
Hospital.DataAcessLayer.CashierManager cManager = new Hospital.DataAcessLayer.CashierManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
DateTime time = Convert.ToDateTime(DateTime.Now.ToLongTimeString());
string Mainbillno = cManager.MainBillDetails(ip, HttpContext.Current.Session["userId"].ToString(), totalAmount, isCredit);
return Mainbillno;
}
}
}
DROPDOWN
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../Forms/CreateAccount.aspx/GetCompanyType",
data: "{}",
dataType: "json",
success: function (Result) {
$.each(Result.d, function (key, value) {
$("#DrpComType").append($("<option></option>").val(value.CompanyTypeId).html(value.CompanyTypeName));
});
},
error: function (Result) {
alert("Error");
}
});
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../Forms/CreateAccount.aspx/GetCompanyType",
data: "{}",
dataType: "json",
success: function (Result) {
$.each(Result.d, function (key, value) {
$("#DrpComType").append($("<option></option>").val(value.CompanyTypeId).html(value.CompanyTypeName));
});
},
error: function (Result) {
alert("Error");
}
});
QRY STRING
var qs = getQueryStrings();
var ReturnId = qs["ReturnId"];
var ReturnBillno = qs["ReturnBillno"];
var ReturnBillType = qs["ReturnBillType"];
var Ipno = qs["Ipno"];
var ReturnBillno = qs["ReturnBillno"];
var ReturnBillType = qs["ReturnBillType"];
var Ipno = qs["Ipno"];
-------
function getQueryStrings() {
var assoc = {};
var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
var queryString = location.search.substring(1);
var keyValues = queryString.split('&');
for (var i in keyValues) {
var key = keyValues[i].split('=');
if (key.length > 1) {
assoc[decode(key[0])] = decode(key[1]);
}
}
return assoc;
}
var assoc = {};
var decode = function (s) { return decodeURIComponent(s.replace(/\+/g, " ")); };
var queryString = location.search.substring(1);
var keyValues = queryString.split('&');
for (var i in keyValues) {
var key = keyValues[i].split('=');
if (key.length > 1) {
assoc[decode(key[0])] = decode(key[1]);
}
}
return assoc;
}
--------------------------------------------------------------------------------------------------
$(document).ready(function () {
window.onload = function () {
var qs = getQueryStrings();
if (!isEmptyObject(qs)) {
var patientID = qs["patientId"];
if (patientID != "") {
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
else {
patientID = "1";
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
}
else {
patientID = "1";
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
}
$("#txtSearchPatient").change(function () {
SearchValue = $("#txtSearchPatient").val();
SearchType = $("#SearchOption").val();
SearchConsultingPatients(SearchValue, SearchType);
});
});
function SearchConsultingPatients(patientID, SearchType) {
var patientId;
var patientName;
var patientSex;
var patientPhone;
var patientAge;
var patientRegDate;
var genderMaleImage = "../Contents/Images/Gender/M.png";
var genderFemaleImage = "../Contents/Images/Gender/W.png"
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/SearchConsultingPatients',
data: "{'patientID':'" + patientID + "','SearchType':'" + SearchType + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (patientsConsulting) {
var patients = JSON.parse(patientsConsulting.d);
$('#consultingList').empty();
if (patients.length != 0) {
$('#consultingList').empty();
for (var i = 0; i < patients.length; i++) {
patientId = patients[i].patientId;
patientName = patients[i].name;
patientSex = patients[i].sex;
patientPhone = patients[i].phNo;
patientAge = patients[i].age;
patientRegDate = patients[i].regDate;
if (patientSex == "Male") {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"><img src="' + genderMaleImage + '" alt="" class="pull-left thumb" height="70px" ><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li> <span class="LabelStyle">RegDate:</span></i> ' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
else {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"> <img src="' + genderFemaleImage + '" alt="" class="pull-left thumb" height="70px"><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li><span class="LabelStyle">RegDate:</span></i>' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
}
}
}
});
}
function loadPatientDetails(patientID) {
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetPatientDetails',
data: "{'patientID':'" + patientID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (patient) {
if (patient.d != null) {
var patient = JSON.parse(patient.d);
if (patient.sex == "Male") {
$("#patientDetails img").attr("src", "../Contents/Images/Gender/M.png")
}
else if (patient.sex == "Female") {
$("#patientDetails img").attr("src", "../Contents/Images/Gender/W.png")
}
$("#patientName").text(patient.name);
$("#patientGender").text(patient.sex);
$("#patientAge").text(patient.age);
$("#patientAddress").text(patient.address);
$("#patientPhone").text(patient.phNo);
$("#patientEmail").text(patient.email);
$("#patientID").text(patient.patientId);
$("#age").text(patient.age);
$("#patientRegiDate").text(patient.regDate);
$("#spnSex").text(patient.sex);
$("#spnId").text(patient.patientId);
}
}
});
}
function loadConsultingPatients() {
var patientId;
var patientName;
var patientSex;
var patientPhone;
var patientAge;
var patientRegDate;
var genderMaleImage = "../Contents/Images/Gender/M.png";
var genderFemaleImage = "../Contents/Images/Gender/W.png"
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetConsultingPatients',
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (patientsConsulting) {
var patients = JSON.parse(patientsConsulting.d);
if (patients.length != 0) {
$('#consultingList').empty();
for (var i = 0; i < patients.length; i++) {
patientId = patients[i].patientId;
patientName = patients[i].name;
patientSex = patients[i].sex;
patientPhone = patients[i].phNo;
patientAge = patients[i].age;
patientRegDate = patients[i].regDate;
if (patientSex == "Male") {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"><img src="' + genderMaleImage + '" alt="" class="pull-left thumb" height="70px" ><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li> <span class="LabelStyle">RegDate:</span></i> ' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
else {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"> <img src="' + genderFemaleImage + '" alt="" class="pull-left thumb" height="70px"><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li><span class="LabelStyle">RegDate:</span></i>' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
}
}
}
});
}
function FillLabDetails(id, idVal) {
$(id).empty();
var X = idVal + 'LabDiv';
var Y = idVal + 'LabTbl';
$(id).last().append('<div id=' + X + ' class="AAA"></div>');
jQuery("div", id).last().append('<table id=' + Y + ' class="ProfileTableCss">');
jQuery("table", id).last().append('<tr><td colspan="3">LAB TEST DETAILS</td></tr>');
jQuery("table", id).last().append('<tr><td style="text-align:center;font-weight:bold">TEST NAME</td><td style="text-align:center;font-weight:bold"> DOCTOR</td><td style="text-align:center;font-weight:bold"> RESULT</td></tr>');
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetInvestigationsAssigned',
data: "{'conId':'" + idVal + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (investigations) {
var investigationsAssigned = JSON.parse(investigations.d);
for (var j = 0; j < investigationsAssigned.length; j++) {
jQuery("table", id).append('<tr><td style="text-align:center;">' + investigationsAssigned[j].investigationName + '</td><td style="text-align:center;">' + investigationsAssigned[j].doctorID + '</td><td style="text-align:center;">' + investigationsAssigned[j].investigationResult + '</td></tr>');
}
}
});
}
function FillMedicineDetails(id, idVal) {
$(id).empty();
var X = idVal + 'MedDiv';
var Y = idVal + 'MedTbl';
$(id).last().append('<div id=' + X + ' class="AAA"></div>');
jQuery("div", id).last().append('<table id=' + Y + ' class="ProfileTableCss">');
jQuery("table", id).last().append('<tr><td colspan="5">PRESCRIBED MEDICINE DETAILS</td></tr>');
jQuery("table", id).last().append('<tr><td style="text-align:center;font-weight:bold">PRODUCT</td><td style="text-align:center;font-weight:bold"> BATCH</td><td style="text-align:center;font-weight:bold">QUANTITY</td><td style="text-align:center;font-weight:bold">Ext.Medicine</td><td style="text-align:center;font-weight:bold">DOCTOR</td></tr>');
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/FetchPrescribedMedicines',
data: "{'conId':'" + idVal + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (Prescriptions) {
var PresAssigned = JSON.parse(Prescriptions.d);
for (var j = 0; j < PresAssigned.length; j++) {
jQuery("table", id).append('<tr><td style="text-align:center;">' + PresAssigned[j].productName + '</td><td style="text-align:center;">' + PresAssigned[j].batch + '</td><td style="text-align:center;">' + PresAssigned[j].qty + '</td><td style="text-align:center;">' + PresAssigned[j].externalMedicine + '</td><td style="text-align:center;">' + PresAssigned[j].doctorId + '</td></tr>');
}
}
});
}
function getConsultationHistory(patientID) {
var consultationData;
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetConsultationHistory',
data: "{'patientID':'" + patientID + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (consultation) {
var consultation = JSON.parse(consultation.d);
$('#HistoryUL').empty();
if (consultation.length != 0) {
for (var i = 0; i < consultation.length; i++) {
var txtDiag = consultation[i].conId + 'DIAG';
var txtConsul = consultation[i].conId + 'CON';
var txtComn = consultation[i].conId + 'COMN';
var txtpreDiag = consultation[i].conId + 'PREDIAG';
var txtTbl = consultation[i].conId + 'Tbl';
$('#HistoryUL').last().append('...........................');
}
CkChange();
}
}
});
return consultationData;
}
window.onload = function () {
var qs = getQueryStrings();
if (!isEmptyObject(qs)) {
var patientID = qs["patientId"];
if (patientID != "") {
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
else {
patientID = "1";
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
}
else {
patientID = "1";
loadPatientDetails(patientID);
getConsultationHistory(patientID)
loadConsultingPatients();
}
}
$("#txtSearchPatient").change(function () {
SearchValue = $("#txtSearchPatient").val();
SearchType = $("#SearchOption").val();
SearchConsultingPatients(SearchValue, SearchType);
});
});
function SearchConsultingPatients(patientID, SearchType) {
var patientId;
var patientName;
var patientSex;
var patientPhone;
var patientAge;
var patientRegDate;
var genderMaleImage = "../Contents/Images/Gender/M.png";
var genderFemaleImage = "../Contents/Images/Gender/W.png"
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/SearchConsultingPatients',
data: "{'patientID':'" + patientID + "','SearchType':'" + SearchType + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (patientsConsulting) {
var patients = JSON.parse(patientsConsulting.d);
$('#consultingList').empty();
if (patients.length != 0) {
$('#consultingList').empty();
for (var i = 0; i < patients.length; i++) {
patientId = patients[i].patientId;
patientName = patients[i].name;
patientSex = patients[i].sex;
patientPhone = patients[i].phNo;
patientAge = patients[i].age;
patientRegDate = patients[i].regDate;
if (patientSex == "Male") {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"><img src="' + genderMaleImage + '" alt="" class="pull-left thumb" height="70px" ><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li> <span class="LabelStyle">RegDate:</span></i> ' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
else {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"> <img src="' + genderFemaleImage + '" alt="" class="pull-left thumb" height="70px"><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li><span class="LabelStyle">RegDate:</span></i>' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
}
}
}
});
}
function loadPatientDetails(patientID) {
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetPatientDetails',
data: "{'patientID':'" + patientID + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (patient) {
if (patient.d != null) {
var patient = JSON.parse(patient.d);
if (patient.sex == "Male") {
$("#patientDetails img").attr("src", "../Contents/Images/Gender/M.png")
}
else if (patient.sex == "Female") {
$("#patientDetails img").attr("src", "../Contents/Images/Gender/W.png")
}
$("#patientName").text(patient.name);
$("#patientGender").text(patient.sex);
$("#patientAge").text(patient.age);
$("#patientAddress").text(patient.address);
$("#patientPhone").text(patient.phNo);
$("#patientEmail").text(patient.email);
$("#patientID").text(patient.patientId);
$("#age").text(patient.age);
$("#patientRegiDate").text(patient.regDate);
$("#spnSex").text(patient.sex);
$("#spnId").text(patient.patientId);
}
}
});
}
function loadConsultingPatients() {
var patientId;
var patientName;
var patientSex;
var patientPhone;
var patientAge;
var patientRegDate;
var genderMaleImage = "../Contents/Images/Gender/M.png";
var genderFemaleImage = "../Contents/Images/Gender/W.png"
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetConsultingPatients',
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (patientsConsulting) {
var patients = JSON.parse(patientsConsulting.d);
if (patients.length != 0) {
$('#consultingList').empty();
for (var i = 0; i < patients.length; i++) {
patientId = patients[i].patientId;
patientName = patients[i].name;
patientSex = patients[i].sex;
patientPhone = patients[i].phNo;
patientAge = patients[i].age;
patientRegDate = patients[i].regDate;
if (patientSex == "Male") {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"><img src="' + genderMaleImage + '" alt="" class="pull-left thumb" height="70px" ><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li> <span class="LabelStyle">RegDate:</span></i> ' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
else {
$('#consultingList').append('<li id="' + patientId + '" class="list-group-item"> <div class="media innerAll half"> <img src="' + genderFemaleImage + '" alt="" class="pull-left thumb" height="70px"><ul class="list-unstyled"> <li><span class="LabelStyle">PatientName:</span>' + patientName + '</li><li><span class="LabelStyle">Phone:</span></i>' + patientPhone + '</li> <li><span class="LabelStyle">RegDate:</span></i>' + patientRegDate + '</li><input class="ConBtn" onclick="ext(this.id)" type="button" id="' + patientId + '" value="Get Details of ' + patientName + '"></input></ul></div></li>');
}
}
}
}
});
}
function FillLabDetails(id, idVal) {
$(id).empty();
var X = idVal + 'LabDiv';
var Y = idVal + 'LabTbl';
$(id).last().append('<div id=' + X + ' class="AAA"></div>');
jQuery("div", id).last().append('<table id=' + Y + ' class="ProfileTableCss">');
jQuery("table", id).last().append('<tr><td colspan="3">LAB TEST DETAILS</td></tr>');
jQuery("table", id).last().append('<tr><td style="text-align:center;font-weight:bold">TEST NAME</td><td style="text-align:center;font-weight:bold"> DOCTOR</td><td style="text-align:center;font-weight:bold"> RESULT</td></tr>');
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetInvestigationsAssigned',
data: "{'conId':'" + idVal + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (investigations) {
var investigationsAssigned = JSON.parse(investigations.d);
for (var j = 0; j < investigationsAssigned.length; j++) {
jQuery("table", id).append('<tr><td style="text-align:center;">' + investigationsAssigned[j].investigationName + '</td><td style="text-align:center;">' + investigationsAssigned[j].doctorID + '</td><td style="text-align:center;">' + investigationsAssigned[j].investigationResult + '</td></tr>');
}
}
});
}
function FillMedicineDetails(id, idVal) {
$(id).empty();
var X = idVal + 'MedDiv';
var Y = idVal + 'MedTbl';
$(id).last().append('<div id=' + X + ' class="AAA"></div>');
jQuery("div", id).last().append('<table id=' + Y + ' class="ProfileTableCss">');
jQuery("table", id).last().append('<tr><td colspan="5">PRESCRIBED MEDICINE DETAILS</td></tr>');
jQuery("table", id).last().append('<tr><td style="text-align:center;font-weight:bold">PRODUCT</td><td style="text-align:center;font-weight:bold"> BATCH</td><td style="text-align:center;font-weight:bold">QUANTITY</td><td style="text-align:center;font-weight:bold">Ext.Medicine</td><td style="text-align:center;font-weight:bold">DOCTOR</td></tr>');
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/FetchPrescribedMedicines',
data: "{'conId':'" + idVal + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (Prescriptions) {
var PresAssigned = JSON.parse(Prescriptions.d);
for (var j = 0; j < PresAssigned.length; j++) {
jQuery("table", id).append('<tr><td style="text-align:center;">' + PresAssigned[j].productName + '</td><td style="text-align:center;">' + PresAssigned[j].batch + '</td><td style="text-align:center;">' + PresAssigned[j].qty + '</td><td style="text-align:center;">' + PresAssigned[j].externalMedicine + '</td><td style="text-align:center;">' + PresAssigned[j].doctorId + '</td></tr>');
}
}
});
}
function getConsultationHistory(patientID) {
var consultationData;
$.ajax({
type: "POST",
url: '../Doctor/Profile.aspx/GetConsultationHistory',
data: "{'patientID':'" + patientID + "'}",
contentType: "application/json; charset-utf-8",
dataType: "json",
async: false,
success: function (consultation) {
var consultation = JSON.parse(consultation.d);
$('#HistoryUL').empty();
if (consultation.length != 0) {
for (var i = 0; i < consultation.length; i++) {
var txtDiag = consultation[i].conId + 'DIAG';
var txtConsul = consultation[i].conId + 'CON';
var txtComn = consultation[i].conId + 'COMN';
var txtpreDiag = consultation[i].conId + 'PREDIAG';
var txtTbl = consultation[i].conId + 'Tbl';
$('#HistoryUL').last().append('...........................');
}
CkChange();
}
}
});
return consultationData;
}
Upload Pic
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Configuration;
using Hospital.core;
using System.IO;
using System.Web.Script.Serialization;
using System.IO.IsolatedStorage;
namespace HospitalManagmentSystem2014.Cashier
{
public partial class UploadPic : System.Web.UI.Page
{
UploadPic Obj;
string username = string.Empty;
string Picture = string.Empty;
string UploadStatus = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
username = Request.QueryString["UserName"];
lblUserName.Text = Request.QueryString["name"];
}
protected void btnUpload_Click(object sender, EventArgs e)
{
Hospital.DataAcessLayer.PreconsultationManager pManager = new Hospital.DataAcessLayer.PreconsultationManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
UploadStatus = upload();
if (UploadStatus == "0")
{
}
else
{
username = Convert.ToString(username);
Picture = UploadStatus;
int retVal = pManager.UploadUserProfilePic(username, Picture, "Cashiers");
if (retVal == 101)
{
Response.Write("<script>alert('Uploaded.....')</script>");
imageLoc.ImageUrl = Picture;
}
}
}
public string upload()
{
string imagePath = "../ProfileImages/";
string FullPath = Server.MapPath("~/ProfileImages/");
try
{
string ext = System.IO.Path.GetExtension(FlUpload.FileName);
if (ext == ".jpg" || ext == ".png")
{
string pathToCreate = "../ProfileImages/" + username + '/';
if ((Directory.Exists(Server.MapPath(pathToCreate))) == true)
{
if (File.Exists(Server.MapPath(pathToCreate + FlUpload.FileName)))
{
imagePath = pathToCreate + FlUpload.FileName;
Response.Write("<script>alert('File name already existed...change name and try again')</script>");
imageLoc.ImageUrl = imagePath;
return "0";
}
else
{
string flPth = FullPath + username + '/' + FlUpload.FileName;
FlUpload.SaveAs(flPth);
imagePath = imagePath + username + '/' + FlUpload.FileName;
}
}
else
{
Directory.CreateDirectory(Server.MapPath(pathToCreate));
FlUpload.SaveAs(FullPath + username + '/' + FlUpload.FileName);
imagePath = imagePath + username + '/' + FlUpload.FileName;
}
}
else
{
Response.Write("<script>alert('File type not supported....')</script>");
}
}
catch (Exception)
{
}
return imagePath;
}
[WebMethod(EnableSession = true)]
public static object RetriveProfilePic(string username)
{
Hospital.core.UserDetails PicPath = new Hospital.core.UserDetails();
string type = "Cashiers";
JavaScriptSerializer serializedData = new JavaScriptSerializer();
Hospital.DataAcessLayer.PreconsultationManager pManager = new Hospital.DataAcessLayer.PreconsultationManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
PicPath = pManager.RetriveProfilePic(username, type);
return serializedData.Serialize(PicPath);
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Configuration;
using Hospital.core;
using System.IO;
using System.Web.Script.Serialization;
using System.IO.IsolatedStorage;
namespace HospitalManagmentSystem2014.Cashier
{
public partial class UploadPic : System.Web.UI.Page
{
UploadPic Obj;
string username = string.Empty;
string Picture = string.Empty;
string UploadStatus = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
username = Request.QueryString["UserName"];
lblUserName.Text = Request.QueryString["name"];
}
protected void btnUpload_Click(object sender, EventArgs e)
{
Hospital.DataAcessLayer.PreconsultationManager pManager = new Hospital.DataAcessLayer.PreconsultationManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
UploadStatus = upload();
if (UploadStatus == "0")
{
}
else
{
username = Convert.ToString(username);
Picture = UploadStatus;
int retVal = pManager.UploadUserProfilePic(username, Picture, "Cashiers");
if (retVal == 101)
{
Response.Write("<script>alert('Uploaded.....')</script>");
imageLoc.ImageUrl = Picture;
}
}
}
public string upload()
{
string imagePath = "../ProfileImages/";
string FullPath = Server.MapPath("~/ProfileImages/");
try
{
string ext = System.IO.Path.GetExtension(FlUpload.FileName);
if (ext == ".jpg" || ext == ".png")
{
string pathToCreate = "../ProfileImages/" + username + '/';
if ((Directory.Exists(Server.MapPath(pathToCreate))) == true)
{
if (File.Exists(Server.MapPath(pathToCreate + FlUpload.FileName)))
{
imagePath = pathToCreate + FlUpload.FileName;
Response.Write("<script>alert('File name already existed...change name and try again')</script>");
imageLoc.ImageUrl = imagePath;
return "0";
}
else
{
string flPth = FullPath + username + '/' + FlUpload.FileName;
FlUpload.SaveAs(flPth);
imagePath = imagePath + username + '/' + FlUpload.FileName;
}
}
else
{
Directory.CreateDirectory(Server.MapPath(pathToCreate));
FlUpload.SaveAs(FullPath + username + '/' + FlUpload.FileName);
imagePath = imagePath + username + '/' + FlUpload.FileName;
}
}
else
{
Response.Write("<script>alert('File type not supported....')</script>");
}
}
catch (Exception)
{
}
return imagePath;
}
[WebMethod(EnableSession = true)]
public static object RetriveProfilePic(string username)
{
Hospital.core.UserDetails PicPath = new Hospital.core.UserDetails();
string type = "Cashiers";
JavaScriptSerializer serializedData = new JavaScriptSerializer();
Hospital.DataAcessLayer.PreconsultationManager pManager = new Hospital.DataAcessLayer.PreconsultationManager(System.Configuration.ConfigurationManager.ConnectionStrings["cnn"].ConnectionString);
PicPath = pManager.RetriveProfilePic(username, type);
return serializedData.Serialize(PicPath);
}
}
}
No comments:
Post a Comment