108 lines
2.9 KiB
C#
108 lines
2.9 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Windows.Forms;
|
|||
|
using Ease.CoreV35.Utility;
|
|||
|
using Ease.CoreV35.Model;
|
|||
|
using Payroll.BO;
|
|||
|
|
|||
|
namespace Payroll.Controls
|
|||
|
{
|
|||
|
public partial class fSearchVendor : Form
|
|||
|
{
|
|||
|
private ObjectsTemplate<Vendor> oVendors = new ObjectsTemplate<Vendor>();
|
|||
|
|
|||
|
public fSearchVendor()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
}
|
|||
|
|
|||
|
public ObjectsTemplate<Vendor> ShowDlg()
|
|||
|
{
|
|||
|
this.ShowDialog();
|
|||
|
return oVendors;
|
|||
|
}
|
|||
|
|
|||
|
private void lvwItems_ColumnClick(object sender, ColumnClickEventArgs e)
|
|||
|
{
|
|||
|
this.Cursor = Cursors.WaitCursor;
|
|||
|
|
|||
|
SortOrder order = SortOrder.Ascending;
|
|||
|
if (order == lvwItems.Sorting)
|
|||
|
order = SortOrder.Descending;
|
|||
|
else
|
|||
|
order = SortOrder.Ascending;
|
|||
|
|
|||
|
lvwItems.ListViewItemSorter = new Global.ItemSorter(e.Column, order);
|
|||
|
lvwItems.Sorting = order;
|
|||
|
|
|||
|
this.Cursor = Cursors.Default;
|
|||
|
}
|
|||
|
|
|||
|
private void btnClose_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
oVendors = null;
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
|
|||
|
private void btnSearch_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
oVendors = Vendor.GetByName(txtSearch.Text.Trim().ToLower());
|
|||
|
LoadListView();
|
|||
|
}
|
|||
|
|
|||
|
private void LoadListView()
|
|||
|
{
|
|||
|
lvwItems.Items.Clear();
|
|||
|
|
|||
|
foreach (Vendor vendor in oVendors)
|
|||
|
{
|
|||
|
ListViewItem item = new ListViewItem();
|
|||
|
item.SubItems.Add(vendor.Name);
|
|||
|
item.Tag = vendor;
|
|||
|
lvwItems.Items.Add(item);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnSelectAll_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
bool isChecked;
|
|||
|
if (btnSelectAll.Text.Equals("Select &All"))
|
|||
|
{
|
|||
|
isChecked = true;
|
|||
|
btnSelectAll.Text = "Remove &All Selection";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
isChecked = false;
|
|||
|
btnSelectAll.Text = "Select &All";
|
|||
|
}
|
|||
|
foreach (ListViewItem item in lvwItems.Items)
|
|||
|
{
|
|||
|
item.Checked = isChecked;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void btnOk_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Vendor oVendor;
|
|||
|
if(lvwItems.CheckedItems.Count==0)
|
|||
|
{
|
|||
|
MessageBox.Show("Select at least one Vendor", "Vendor Search", MessageBoxButtons.OK,
|
|||
|
MessageBoxIcon.Exclamation);
|
|||
|
}
|
|||
|
oVendors = new ObjectsTemplate<Vendor>();
|
|||
|
foreach (ListViewItem item in lvwItems.CheckedItems)
|
|||
|
{
|
|||
|
oVendor = (Vendor) item.Tag;
|
|||
|
oVendors.Add(oVendor);
|
|||
|
}
|
|||
|
this.Close();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|