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.Model; using Payroll.BO; namespace Payroll.Controls.CustomControls { public partial class fSearchDisciplineAction : Form { private bool _isCancel; private ObjectsTemplate _DActionMasters = null; #region Property DACode : String private string _DACode; public string DACode { get { return _DACode; } set { _DACode = value; } } #endregion public fSearchDisciplineAction() { InitializeComponent(); _isCancel = true; } public bool ShowDlg() { this.ShowDialog(); return _isCancel; } private void btnSearch_Click(object sender, EventArgs e) { string sql = string.Empty; lvwItems.Items.Clear(); sql += "Select * from DAMASTER"; if(txtCode.Text.Trim().Length>0) { sql += " Where DAMCODE='" + txtCode.Text.Trim()+"'"; sql += " And DAMDATE BETWEEN '" + dtpFromDate.Value + "' and '" + dtpToDate.Value + "'"; } else { sql += " Where DAMDATE BETWEEN '" + dtpFromDate.Value + "' and '" + dtpToDate.Value + "'"; } _DActionMasters= DAMaster.GetDAs(sql); if(_DActionMasters!=null) { foreach (DAMaster oDActionMaster in _DActionMasters) { ListViewItem oItem = null; oItem = new ListViewItem(oDActionMaster.DAMCode); oItem.SubItems.Add(oDActionMaster.DAMNote); oItem.SubItems.Add(oDActionMaster.DAMDate.ToString("dd MMM yyyy")); oItem.Tag = oDActionMaster; lvwItems.Items.Add(oItem); } } } private void btnOk_Click(object sender, EventArgs e) { if (lvwItems.SelectedItems.Count > 0) { DACode = ((DAMaster)lvwItems.SelectedItems[0].Tag).DAMCode; } else { MessageBox.Show("Please select any item", "DActionMaster", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } _isCancel = false; this.Close(); } private void btnClose_Click(object sender, EventArgs e) { this.Close(); } } }