private void BindList() { DataTable tblIncluded = CDL.GetDSIncludedEmployee(_strCDLCode); lvIncluded.Items.Clear(); foreach (DataRow drw in tblIncluded.Rows) { ListViewItem lvi = new ListViewItem(); lvi.Tag = drw["username"].ToString(); lvi.Text = drw["lastname"].ToString() + ", " + drw["firname"].ToString(); lvIncluded.Items.Add(lvi); } DataTable tblExclude = CDL.GetDSExcludedEmployee(_strCDLCode); lvExcluded.Items.Clear(); foreach (DataRow drw in tblExclude.Rows) { ListViewItem lvi = new ListViewItem(); lvi.Tag = drw["username"].ToString(); lvi.Text = drw["lastname"].ToString() + ", " + drw["firname"].ToString(); lvi.SubItems.Add(LeaveApplicationBalance.GetRemainingBalance(drw["username"].ToString(), cmbLeaveType.SelectedValue.ToString()).ToString()); lvExcluded.Items.Add(lvi); } }
private void btnExcludeAll_Click(object sender, EventArgs e) { foreach (ListViewItem itm in lvIncluded.Items) { bool blnCancelLeave = false; bool blnHasBalance = false; string strLeaveTypeCode = ""; string strUsername = itm.Tag.ToString(); string strLeaveCode = CDL.GetLeaveCode(strUsername, _strCDLCode); using (LeaveApplication leave = new LeaveApplication()) { leave.LeaveCode = strLeaveCode; leave.Fill(); strLeaveTypeCode = leave.LeaveType; leave.Status = "C"; blnCancelLeave = leave.UpdateAdmin() > 0; } blnHasBalance = LeaveApplicationTypes.IsHasBalance(strLeaveTypeCode); if (blnHasBalance && blnCancelLeave) { LeaveApplicationBalance.AddLeaveBalance(1, strUsername, strLeaveTypeCode); } if (blnCancelLeave) { CDL.RemoveMember(_strCDLCode, strUsername); } } this.BindList(); }
private void btnInclude_Click(object sender, EventArgs e) { if (lvExcluded.SelectedItems.Count > 0) { bool blnInsertLeave = false; bool blnHasBalance = LeaveApplicationTypes.IsHasBalance(cmbLeaveType.SelectedValue.ToString()); string strLeaveCode = ""; string strUsername = lvExcluded.SelectedItems[0].Tag.ToString(); DateTime dteDateStart = DateTime.Now; DateTime dteDateEnd = DateTime.Now; using (clsShift shift = new clsShift()) { shift.ShiftCode = clsShift.GetDayShiftCode(strUsername, clsDateTime.GetDateOnly(dtpDateApplied.Value)); shift.Fill(); dteDateStart = clsDateTime.CombineDateTime(dtpDateApplied.Value, shift.TimeStart); dteDateEnd = clsDateTime.CombineDateTime(dtpDateApplied.Value, shift.TimeEnd); } if ((clsValidator.CheckFloat(lvExcluded.SelectedItems[0].SubItems[1].Text) >= 1) || (!blnHasBalance)) { using (LeaveApplication leave = new LeaveApplication()) { leave.LeaveType = cmbLeaveType.SelectedValue.ToString(); leave.Requestor = strUsername; leave.DateFile = DateTime.Now; leave.DateStart = dteDateStart; leave.DateEnd = dteDateEnd; leave.Units = 1; leave.Reason = txtReason.Text; leave.Approver = HRMSCore.Username; leave.ApproverDate = DateTime.Now; leave.ApproverRemarks = "CDL Application. Auto-generated"; leave.Status = "A"; blnInsertLeave = leave.InsertAdmin(); strLeaveCode = leave.LeaveCode; } if (blnHasBalance && blnInsertLeave) { LeaveApplicationBalance.DeductLeaveBalance(1, strUsername, cmbLeaveType.SelectedValue.ToString()); } if (blnInsertLeave) { CDL.InsertMember(_strCDLCode, strUsername, strLeaveCode); this.BindList(); } } else { MessageBox.Show(lvExcluded.SelectedItems[0].Tag.ToString() + " has not enough balance.", clsMessageBox.MessageBoxText, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
private void btnSave_Click(object sender, EventArgs e) { using (CDL objCDL = new CDL()) { objCDL.CDLCode = _strCDLCode; objCDL.Fill(); objCDL.Reason = txtReason.Text; objCDL.Update(); } _frmCDLList.LoadCDLList(); this.Close(); }
private void tbtnDelete_Click(object sender, EventArgs e) { if (lvCDL.SelectedItems.Count > 0) { if (MessageBox.Show(clsMessageBox.MessageBoxDeleteAsk, clsMessageBox.MessageBoxText, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { CDL objCDL = new CDL(); objCDL.CDLCode = lvCDL.SelectedItems[0].Tag.ToString(); objCDL.Delete(); LoadCDLList(); } } }
private void btnSave_Click(object sender, EventArgs e) { if (IsCorrectData()) { using (CDL objCDL = new CDL()) { objCDL.DateApplied = dtpDateApplied.Value; objCDL.Reason = txtReason.Text; objCDL.Insert(); } this.Close(); _frmCDLList.LoadCDLList(); } }
private void BindDetails() { lblCDLCode.Text = _strCDLCode; using (CDL objCDL = new CDL()) { objCDL.CDLCode = _strCDLCode; objCDL.Fill(); dtpDateApplied.Value = objCDL.DateApplied; txtReason.Text = objCDL.Reason; lblCreatedBy.Text = objCDL.CreatedBy; lblDateCreated.Text = objCDL.CreatedOn.ToString("MMM dd, yyyy"); lblModifiedBy.Text = objCDL.ModifiedBy; lblDateModified.Text = objCDL.ModifiedOn.ToString("MMM dd, yyyy"); } }
public void LoadCDLList() { DataTable tblCDL = CDL.GetDSGMainForm(); lvCDL.Items.Clear(); foreach (DataRow drw in tblCDL.Rows) { ListViewItem lvi = new ListViewItem(); lvi.Text = drw["cdlcode"].ToString(); lvi.Tag = drw["cdlcode"].ToString(); lvi.SubItems.Add(clsValidator.CheckDate(drw["dateapp"].ToString()).ToString("MMM dd, yyyy")); lvi.SubItems.Add(drw["preason"].ToString()); lvi.BackColor = (lvCDL.Items.Count % 2 == 0 ? Color.White : Color.Ivory); lvCDL.Items.Add(lvi); } }
private void cmbLeaveType_SelectedIndexChanged(object sender, EventArgs e) { try { DataTable tblExclude = CDL.GetDSExcludedEmployee(_strCDLCode); lvExcluded.Items.Clear(); foreach (DataRow drw in tblExclude.Rows) { ListViewItem lvi = new ListViewItem(); lvi.Tag = drw["username"].ToString(); lvi.Text = drw["lastname"].ToString() + ", " + drw["firname"].ToString(); lvi.SubItems.Add(LeaveApplicationBalance.GetRemainingBalance(drw["username"].ToString(), cmbLeaveType.SelectedValue.ToString()).ToString()); lvExcluded.Items.Add(lvi); } } catch { } }
/// <summary> /// 从InnerDB数据库上获取cit文件上具体线路的长短链(只适用于一个cit文件) /// </summary> /// <param name="sKmInc">增里程还是减里程</param> /// <param name="sTrackCode">线路编号</param> /// <param name="sDir">行别</param> /// <returns>长短链信息</returns> public List <CDL> GetCDL(string sKmInc, string sTrackCode, string sDir) { List <CDL> listCDL = new List <CDL>(); try { string connectionStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\InnerDB.idf;Persist Security Info=True;Mode=Share Exclusive;Jet OLEDB:Database Password=iicdc;"; using (OleDbConnection sqlconn = new OleDbConnection(connectionStr)) { string sSql = ""; if (sKmInc.Contains("减")) { sSql = "desc"; } OleDbCommand sqlcom = new OleDbCommand(" select * from 长短链 where 线编号='" + sTrackCode + "' and 行别='" + sDir + "' order by 公里 " + sSql, sqlconn); sqlconn.Open(); OleDbDataReader sdr = sqlcom.ExecuteReader(); while (sdr.Read()) { CDL cdcl = new CDL(); cdcl.dKM = (float)sdr.GetValue(2); cdcl.iMeter = (int)sdr.GetValue(3); cdcl.sType = sdr.GetValue(4).ToString(); listCDL.Add(cdcl); } sdr.Close(); sqlconn.Close(); } } catch { } return(listCDL); }