CEL_Payroll/Payroll.Controls/CustomControls/ctlCustomControl2.cs

97 lines
2.5 KiB
C#
Raw Normal View History

2024-09-17 14:30:13 +06:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Payroll.BO;
namespace Payroll.Controls
{
public partial class ctlCustomControl2 : UserControl
{
public PayScaleDetail _selSlab=null;
public event System.EventHandler Changed;
public ctlCustomControl2()
{
InitializeComponent();
}
public PayScaleDetail SelectedSlab
{
get { return _selSlab; }
set
{
_selSlab = value;
}
}
public void Clear()
{
this.btnClear_Click(null, null);
}
private void lblText_Click(object sender, EventArgs e)
{
}
private void ctlCustomControl2_Resize(object sender, EventArgs e)
{
lblText.Left = 1;
btnPick.Left = lblText.Width + 1;
btnClear.Left = btnPick.Left + btnPick.Width + 4;
}
private void btnPick_Click(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
frmGradePicker fgp = new frmGradePicker();
fgp.ShowDialog();
if (fgp.SelectedItem != null)
{
this.SelectedSlab = fgp.SelectedItem;
RefreshMe();
}
try
{
if (Changed != null)
{
Changed(sender, e);
}
this.Cursor = Cursors.Default;
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
private void RefreshMe()
{
if (this.SelectedSlab == null)
{
lblText.Text ="";
}
else
{
Grade grd = Grade.Get(this.SelectedSlab.GradeID);
lblText.Text = grd.Code + "/" + this.SelectedSlab.StepNo;
}
}
private void lblText_TextChanged(object sender, EventArgs e)
{
if (lblText.Text == "")
btnClear.Enabled = false;
else
btnClear.Enabled = true;
}
private void btnClear_Click(object sender, EventArgs e)
{
this.SelectedSlab = null;
RefreshMe();
if (Changed != null)
Changed(sender, e);
}
}
}