using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TORServices.FormsTor
{
#region _DataGridViewDatetimepickerColumn
public class DataGridViewDatetimepickerColumn : System.Windows.Forms.DataGridViewColumn
{
public DataGridViewDatetimepickerColumn()
: base(new DataGridViewDatetimepickerCell())
{
}
private string customFormat = "yyyy-MM-dd hh:mm:ss";
[
System.ComponentModel.DefaultValue(null),
System.ComponentModel.Localizable(true),
System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.Repaint)
]
[System.ComponentModel.Category("Behavior")]
public string CustomFormat
{
get
{
return customFormat;
}
set
{
if ((value != null && !value.Equals(customFormat)) ||
(value == null && customFormat != null))
{
customFormat = value;
}
}
}
private System.Windows.Forms.DateTimePickerFormat _PickerFormat = System.Windows.Forms.DateTimePickerFormat.Custom;
[System.ComponentModel.Browsable(true)]
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Always)]
[System.ComponentModel.Category("Behavior")]
[System.ComponentModel.Description("Open Dialog is dispalyed and on success the contents of the Cell is replaced with the new path.")]
public System.Windows.Forms.DateTimePickerFormat PickerFormat
{
get { return _PickerFormat; }
set
{
_PickerFormat = value;
}
}
public override object Clone()
{
var clm = base.Clone() as DataGridViewDatetimepickerColumn;
DataGridViewDatetimepickerColumn xxx = base.Clone() as DataGridViewDatetimepickerColumn;
if (clm != null)
{
clm.PickerFormat = _PickerFormat;
clm.CustomFormat = customFormat;
}
return clm;
}
public override System.Windows.Forms.DataGridViewCell CellTemplate
{
get { return base.CellTemplate; }
set
{
if ((value != null) && !value.GetType().IsAssignableFrom(typeof(DataGridViewDatetimepickerCell)))
{
throw new InvalidCastException("Must be a DataGridViewDatetimepickerCell");
}
base.CellTemplate = value;
}
}
}
public class DataGridViewDatetimepickerCell : System.Windows.Forms.DataGridViewTextBoxCell
{
public DataGridViewDatetimepickerCell()
{
}
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle)
{
// Set the value of the editing control to the current cell value.
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
DataGridViewDatetimepickerEdit ctl = (DataGridViewDatetimepickerEdit)DataGridView.EditingControl;
if ((!object.ReferenceEquals(this.Value, DBNull.Value)))
{
if ((this.Value != null))
{
ctl.Value = (DateTime)this.Value;
}
}
DataGridViewDatetimepickerColumn fileColumn = (DataGridViewDatetimepickerColumn)this.DataGridView.Columns[ColumnIndex];
ctl.Format = fileColumn.PickerFormat;
}
public override Type EditType
{
// Return the type of the editing contol that DataGridViewDatetimepickerCell uses.
get { return typeof(DataGridViewDatetimepickerEdit); }
}
public override Type ValueType
{
// Return the type of the value that DataGridViewDatetimepickerCell contains.
get { return typeof(DateTime); }
}
}
class DataGridViewDatetimepickerEdit : System.Windows.Forms.DateTimePicker, System.Windows.Forms.IDataGridViewEditingControl
{
private System.Windows.Forms.DataGridView dataGridViewControl;
private bool valueIsChanged = false;
private int rowIndexNum;
public DataGridViewDatetimepickerEdit()
{
this.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
}
public object EditingControlFormattedValue
{
get { return this.Value.ToShortDateString(); }
set
{
if (value is String)
{
this.Value = DateTime.Parse(Convert.ToString(value));
}
}
}
public object GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context)
{
return this.Value.ToShortDateString();
}
public void ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle)
{
this.Font = dataGridViewCellStyle.Font;
this.CalendarForeColor = dataGridViewCellStyle.ForeColor;
this.CalendarMonthBackground = dataGridViewCellStyle.BackColor;
}
public int EditingControlRowIndex
{
get { return rowIndexNum; }
set { rowIndexNum = value; }
}
public bool EditingControlWantsInputKey(System.Windows.Forms.Keys key, bool dataGridViewWantsInputKey)
{
// Let the DateTimePicker handle the keys listed.
switch (key & System.Windows.Forms.Keys.KeyCode)
{
case System.Windows.Forms.Keys.Left:
case System.Windows.Forms.Keys.Up:
case System.Windows.Forms.Keys.Down:
case System.Windows.Forms.Keys.Right:
case System.Windows.Forms.Keys.Home:
case System.Windows.Forms.Keys.End:
case System.Windows.Forms.Keys.PageDown:
case System.Windows.Forms.Keys.PageUp:
return true;
default:
return false;
}
}
public void PrepareEditingControlForEdit(bool selectAll)
{
// No preparation needs to be done.
}
public bool RepositionEditingControlOnValueChange
{
get { return false; }
}
public System.Windows.Forms.DataGridView EditingControlDataGridView
{
get { return dataGridViewControl; }
set { dataGridViewControl = value; }
}
public bool EditingControlValueChanged
{
get { return valueIsChanged; }
set { valueIsChanged = value; }
}
public System.Windows.Forms.Cursor EditingControlCursor
{
get { return base.Cursor; }
}
System.Windows.Forms.Cursor System.Windows.Forms.IDataGridViewEditingControl.EditingPanelCursor
{
get { return EditingControlCursor; }
}
protected override void OnValueChanged(EventArgs eventargs)
{
// Notify the DataGridView that the contents of the cell have changed.
valueIsChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnValueChanged(eventargs);
}
}
#endregion
}
if object_id('tempdb..#temp') is not null drop table #temp;
declare @recordstotal int;
declare @recordsfiltered int;
set @recordsfiltered = (select count(1) from jvh);
select * into #temp
from
(
select a.*, b.BDesc, b.BDesc2 from jvh a
left join book b on a.jvbook = b.bcode
--left join VIP_Class c on b.VIP_Class = c.VIP_Class
where a.pflag like '%%' or a.pflag is null
) as temp;
set @recordstotal = (select count(1) from #temp);
select * from #temp tempdata order by jvno desc offset 0 rows fetch next 10 rows only;
select @recordstotal as recordstotal, @recordsfiltered as recordsfiltered;
if object_id('tempdb..#temp') is not null drop table #temp;
public partial class DatetimeSelect : UserControl
{
private System.Windows.Forms.DateTimePicker dpkDate;
private System.Windows.Forms.DateTimePicker dpkTime;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dpkDate = new System.Windows.Forms.DateTimePicker();
this.dpkTime = new System.Windows.Forms.DateTimePicker();
this.SuspendLayout();
//
// dpkDate
//
this.dpkDate.Dock = System.Windows.Forms.DockStyle.Fill;
this.dpkDate.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dpkDate.Location = new System.Drawing.Point(0, 0);
this.dpkDate.Margin = new System.Windows.Forms.Padding(4);
this.dpkDate.Name = "dpkDate";
this.dpkDate.Size = new System.Drawing.Size(118, 24);
this.dpkDate.TabIndex = 0;
//
// dpkTime
//
this.dpkTime.Dock = System.Windows.Forms.DockStyle.Right;
this.dpkTime.Format = System.Windows.Forms.DateTimePickerFormat.Time;
this.dpkTime.Location = new System.Drawing.Point(118, 0);
this.dpkTime.Margin = new System.Windows.Forms.Padding(4);
this.dpkTime.Name = "dpkTime";
this.dpkTime.ShowUpDown = true;
this.dpkTime.Size = new System.Drawing.Size(119, 24);
this.dpkTime.TabIndex = 1;
//
// DatetimeSelect
//
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.dpkDate);
this.Controls.Add(this.dpkTime);
this.Font = new System.Drawing.Font("Microsoft Sans Serif", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(222)));
this.Margin = new System.Windows.Forms.Padding(4);
this.Name = "DatetimeSelect";
this.Size = new System.Drawing.Size(237, 29);
this.ResumeLayout(false);
}
#endregion
public DatetimeSelect()
{
InitializeComponent();
}
#region _Properties
private DateTime value = DateTime.Now;
[
Bindable(true),
RefreshProperties(RefreshProperties.All)
]
public DateTime Value
{
get
{
return value;
}
set
{
this.value = value;
dpkDate.Value = value;
dpkTime.Value = value;
}
}
[
DefaultValue(false)
]
public bool ShowUpDownDate
{
get
{
return dpkDate.ShowUpDown;
}
set
{
dpkDate.ShowUpDown = value;
}
}
#endregion
#region _Event
private EventHandler onValueChanged;
protected virtual void OnValueChanged(EventArgs eventargs)
{
if (onValueChanged != null)
{
onValueChanged(this, eventargs);
}
}
#endregion
}
Code (C#)
namespace TORServices.FormsTor
{
#region _DataGridViewDatetimeSelectColumn
public class DataGridViewDatetimeSelectColumn : System.Windows.Forms.DataGridViewColumn
{
public DataGridViewDatetimeSelectColumn()
: base(new DataGridViewDatetimeSelectCell())
{
}
}
public class DataGridViewDatetimeSelectCell : System.Windows.Forms.DataGridViewTextBoxCell
{
public DataGridViewDatetimeSelectCell()
:base()
{
}
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle)
{
// Set the value of the editing control to the current cell value.
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
DataGridViewDatetimeSelectEdit ctl = (DataGridViewDatetimeSelectEdit)DataGridView.EditingControl;
if ((!object.ReferenceEquals(this.Value, DBNull.Value)))
{
if ((this.Value != null))
{
ctl.Value = (DateTime)this.Value;
}
}
DataGridViewDatetimeSelectColumn fileColumn = (DataGridViewDatetimeSelectColumn)this.DataGridView.Columns[ColumnIndex];
}
public override Type EditType
{
// Return the type of the editing contol that DataGridViewDatetimeSelectCell uses.
get { return typeof(DataGridViewDatetimeSelectEdit); }
}
}
class DataGridViewDatetimeSelectEdit : DatetimeSelect, System.Windows.Forms.IDataGridViewEditingControl
{
private System.Windows.Forms.DataGridView dataGridViewControl;
private bool valueIsChanged = false;
private int rowIndexNum;
public DataGridViewDatetimeSelectEdit()
{
}
public object EditingControlFormattedValue
{
get { return this.Value; }
set
{
if (value is String)
{
this.Value = DateTime.Parse(Convert.ToString(value));
}
}
}
public object GetEditingControlFormattedValue(System.Windows.Forms.DataGridViewDataErrorContexts context)
{
return this.Value;
}
public void ApplyCellStyleToEditingControl(System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle)
{
}
public int EditingControlRowIndex
{
get { return rowIndexNum; }
set { rowIndexNum = value; }
}
public bool EditingControlWantsInputKey(System.Windows.Forms.Keys key, bool dataGridViewWantsInputKey)
{
// Let the DateTimePicker handle the keys listed.
switch (key & System.Windows.Forms.Keys.KeyCode)
{
case System.Windows.Forms.Keys.Left:
case System.Windows.Forms.Keys.Up:
case System.Windows.Forms.Keys.Down:
case System.Windows.Forms.Keys.Right:
case System.Windows.Forms.Keys.Home:
case System.Windows.Forms.Keys.End:
case System.Windows.Forms.Keys.PageDown:
case System.Windows.Forms.Keys.PageUp:
return true;
default:
return false;
}
}
public void PrepareEditingControlForEdit(bool selectAll)
{
// No preparation needs to be done.
}
public bool RepositionEditingControlOnValueChange
{
get { return false; }
}
public System.Windows.Forms.DataGridView EditingControlDataGridView
{
get { return dataGridViewControl; }
set { dataGridViewControl = value; }
}
public bool EditingControlValueChanged
{
get { return valueIsChanged; }
set { valueIsChanged = value; }
}
public System.Windows.Forms.Cursor EditingControlCursor
{
get { return base.Cursor; }
}
System.Windows.Forms.Cursor System.Windows.Forms.IDataGridViewEditingControl.EditingPanelCursor
{
get { return EditingControlCursor; }
}
protected override void OnValueChanged(EventArgs eventargs)
{
// Notify the DataGridView that the contents of the cell have changed.
valueIsChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnValueChanged(eventargs);
}
}
#endregion
}
public class DataGridViewDatetimeSelectCell : System.Windows.Forms.DataGridViewTextBoxCell
{
public DataGridViewDatetimeSelectCell()
:base()
{
}
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle)
{
// Set the value of the editing control to the current cell value.
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
DataGridViewDatetimeSelectEdit ctl = (DataGridViewDatetimeSelectEdit)DataGridView.EditingControl;
if ((!object.ReferenceEquals(this.Value, DBNull.Value)))
{
if ((this.Value != null))
{
ctl.Value = (DateTime)this.Value;
}
}
DataGridViewDatetimeSelectColumn fileColumn = (DataGridViewDatetimeSelectColumn)this.DataGridView.Columns[ColumnIndex];
ctl.ShowUpDownDate = fileColumn.ShowUpDownDate;
}
public override Type EditType
{
// Return the type of the editing contol that DataGridViewDatetimeSelectCell uses.
get { return typeof(DataGridViewDatetimeSelectEdit); }
}
}
1. Vue3 JavaScript Framework
--- OK ใส่เข้าไปแล้ว หนึ่งหน้า (ข้อมูลแผนก) +55555
2. Blazor and .NET 5
--- คิดเอาไว้ อย่างน้อยฯเยอะมาก อธิบายไม่ไหว ดูรูปเอาเองก็แล้วกัน
------ ถ้าจัดการ JavaScript/Jquery อยู่หมัด ก็น่าจะทำเป็น Production ได้
File Index.rasor Code (C#)
@page "/"
@inject IJSRuntime JSRuntime
@implements IAsyncDisposable
<h1>Hello, world!</h1>
<div class="alert alert-warning" role="alert">
Before authentication will function correctly, you must configure your provider details in <code>Program.cs</code>
</div>
Welcome to your new app.
<SurveyPrompt Title="How is Blazor working for you?" />
<div class="alert alert-warning" role="alert">
Fucker JavaScript/Jquery in Blazor Web Assembly without <code>@("<script src='YouPath/js/Fucker.js'></script>")</code>
</div>
Enter your name:
<input @bind="name" />
<button @onclick="Submit">Submit</button>
<input @bind="name" />
@retValue
@code {
private string name;
private string retValue;
// Load the module and keep a reference to it
// You need to use .AsTask() to convert the ValueTask to Task as it may be awaited multiple times
private Task<IJSObjectReference> _module;
private Task<IJSObjectReference> Module => _module ??= JSRuntime.InvokeAsync<IJSObjectReference>("import", "./js/demo.js").AsTask();
async Task Submit() {
var module = await Module;
await module.InvokeVoidAsync("sayHi", name);
retValue = await module.InvokeAsync<string>("Fucker", name);
}
public async ValueTask DisposeAsync() {
if (_module != null) {
var module = await _module;
await module.DisposeAsync();
}
}
}
File demo.js Code (JavaScript)
// Use the module syntax to export the function
export function sayHi(name) {
alert(`Hello ${name}!`);
}
export function Fucker(name) {
return name + " HiHa";
}
<FuckerScript>
<script>
var JiMi = "wow wow wow";
$(function () {
$("#btnHacks").on("click", function () {
alert("sayHi aHa " + JiMi);
});
});
////If you want to include a JS file in a JS you can use jQuery.getScript() for that
//$.getScript('test1.js', function () {
// //script is loaded and executed put your dependent JS here
// test1();
//});
////And if you cannot use jQuery
//var imported = document.createElement('script');
//imported.src = '/path/to/imported/script';
//document.head.appendChild(imported);
////document.getElementsByTagName('head')[0].appendChild(...)
//document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", "<link rel=\"stylesheet\" href=\"path/to/style.css\" />");
</script>
</FuckerScript>