internal DataSet InsertLeave(LeaveData leaveData) { DataSet ds = new DataSet(); using (SqlConnection conn = new SqlConnection(AmecUtilDBConnection)) { SqlCommand cmd = conn.CreateCommand(); cmd.CommandText = "amec_leaves_submit"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("operation", 1); cmd.Parameters.AddWithValue("ntid", leaveData.LeaveUser.NtId); cmd.Parameters.AddWithValue("leaveType", leaveData.LeaveType); cmd.Parameters.AddWithValue("leaveTypeDesc", leaveData.LeaveTypeDesc); cmd.Parameters.AddWithValue("leaveDateType", leaveData.LeaveDateType); cmd.Parameters.AddWithValue("leaveDateStr", leaveData.LeaveDates); cmd.Parameters.AddWithValue("leaveRemarks", leaveData.LeaveRemarks); try { SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; da.Fill(ds); } catch (Exception ex) { throw ex; } } return(ds); }
protected void lbuCancelProgressFinish_Click(object sender, EventArgs e) { LeaveData leaveData = (LeaveData)Session["LeaveData"]; leaveData.ExecuteCancelByUser(); MV1.ActiveViewIndex = 3; }
private void AddLeaveData(LeaveApplication lvappl, LeaveType lvType, DateTime datetime) { string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd"); LeaveData _LVData = new LeaveData(); _LVData.EmpID = lvappl.EmpID; if (lvappl.IsHalf == true) { _LVData.HalfLeave = true; } else { _LVData.HalfLeave = false; } _LVData.PLeaveDataEmpDate = _EmpDate; _LVData.Remarks = lvappl.LeaveReason; _LVData.IsAccum = lvappl.IsAccum; _LVData.LeaveAppID = lvappl.PLeaveAppID; _LVData.AttDate = datetime.Date; _LVData.LeaveTypeID = lvappl.LeaveTypeID; try { LeaveDataRepo.Add(_LVData); LeaveDataRepo.Save(); } catch (Exception ex) { } }
protected void lbuAddComment_Click(object sender, EventArgs e) { if (tbF1Comment.Text == "" || (!rbAllow.Checked && !rbNotAllow.Checked)) { error_area.Attributes["class"] = "alert alert_danger"; error_area.InnerHtml = ""; error_area.InnerHtml += "<strong>เกิดข้อผิดพลาด!</strong><br>"; if (tbF1Comment.Text == "") { error_area.InnerHtml += "<div class='hm_tab'></div>- กรุณากรอก <strong>ความเห็น</strong><br>"; } if (!rbAllow.Checked && !rbNotAllow.Checked) { error_area.InnerHtml += "<div class='hm_tab'></div>- กรุณาเลือก <strong>การอนุมัติ</strong><br>"; } } else { error_area.Attributes["class"] = null; error_area.InnerHtml = ""; MultiView1.ActiveViewIndex = 2; int allow = 1; if (rbNotAllow.Checked) { allow = 2; } LeaveData leaveData = (LeaveData)Session["LeaveData"]; LeaveBossData leaveBossData = leaveData.GetCurrentBoss(); if (leaveData.LeaveStatusID == 1) { leaveBossData.Comment = tbF1Comment.Text; leaveBossData.Allow = allow; leaveBossData.AllowDate = DateTime.Today; leaveData.ExecuteAllow(); } else if (leaveData.LeaveStatusID == 4) { leaveBossData.CancelComment = tbF1Comment.Text; leaveBossData.CancelAllow = allow; leaveBossData.CancelAllowDate = DateTime.Today; leaveData.ExecuteCancelAllow(); } /*if (leaveData.LeaveStatusID == 2) { * leaveData.CH_Comment = tbF1Comment.Text; * leaveData.CH_Allow = allow; * leaveData.CH_Date = DateTime.Today; * leaveData.ExecuteAllow(); * } else if (leaveData.LeaveStatusID == 6) { * leaveData.CH_CancelComment = tbF1Comment.Text; * leaveData.CH_CancelAllow = allow; * leaveData.CH_CancelDate = DateTime.Today; * leaveData.ExecuteCancelAllow(); * }*/ } }
public void LeaveApproval(LeaveViewModel lvm) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <LeaveViewModel, LeaveData>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); LeaveData l = mapper.Map <LeaveViewModel, LeaveData>(lvm); pr.LeaveApproval(l); }
public void ApplyLeave(NewLeaveViewModel nlvm) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <NewLeaveViewModel, LeaveData>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); LeaveData l = mapper.Map <NewLeaveViewModel, LeaveData>(nlvm); _employeeRepository.ApplyLeave(l); }
public void LeaveApproval(LeaveData l) { LeaveData ld; ld = db.LeaveDatas.Where(temp => temp.EmployeeID == l.EmployeeID).FirstOrDefault(); ld.ApprovalStatus = l.ApprovalStatus; db.SaveChanges(); }
public LeaveViewModel ViewLeaveByLeaveID(int eid, int lid) { LeaveData ld = er.ViewLeaveByLeaveID(eid, lid); var config = new MapperConfiguration(cfg => { cfg.CreateMap <LeaveData, LeaveViewModel>(); cfg.IgnoreUnmapped(); }); IMapper mapper = config.CreateMapper(); LeaveViewModel lvm = mapper.Map <LeaveData, LeaveViewModel>(ld); return(lvm); }
public void LeaveApproval(LeaveData l) { var appDbContext = new LeaveManagementDbContext(); var userStore = new ApplicationUserStore(appDbContext); var userManager = new ApplicationUserManager(userStore); LeaveData ld = _db.LeaveDatas.Where(temp => temp.LeaveID == l.LeaveID).FirstOrDefault(); ld.ApprovedBy = HttpContext.Current.User.Identity.GetUserName(); ld.ApprovalStatus = l.ApprovalStatus; _db.SaveChanges(); }
protected void lbuCancelFinish_Click(object sender, EventArgs e) { LeaveData leaveData = (LeaveData)Session["LeaveData"]; leaveData.CancelReason = tbCancelReason.Text; leaveData.ExecuteCancel(); ClearNotification(); //ChangeNotification("success", "<strong>ยกเลิกลาสำเร็จ!</strong> คุณสามารถตรวจสอบสถานะการลาได้ที่เมนู การลา -> สถานะ และ ประวัติการลา"); MV1.ActiveViewIndex = 2; }
public void DeleteHLFromLVData(LeaveApplication lvappl) { int _EmpID = lvappl.EmpID; DateTime Date = lvappl.FromDate; while (Date <= lvappl.ToDate) { Expression <Func <LeaveData, bool> > SpecificEntrie = aa => aa.EmpID == _EmpID && aa.AttDate == Date.Date; if (LeaveDataRepo.FindBy(SpecificEntrie).Count() > 0) { var _id = LeaveDataRepo.FindBy(SpecificEntrie).FirstOrDefault().PLeaveDataEmpDate; LeaveData lvvdata = LeaveDataRepo.GetSingle(_id); //lvvdata.Active = false; LeaveDataRepo.Delete(lvvdata); LeaveDataRepo.Save(); } Date = Date.AddDays(1); } }
protected void btnLeaveSubmit_Click(object sender, EventArgs e) { LeaveData leaveData = new LeaveData(); leaveData.LeaveType = Convert.ToInt32(ddlLeaveType.SelectedValue.ToString()); leaveData.LeaveTypeDesc = Enums.GetDescription((Enums.LeaveTypes)leaveData.LeaveType); Enums.LeaveDateTypes leaveDateTypes = (Enums.LeaveDateTypes)Enum.Parse(typeof(Enums.LeaveDateTypes), Request.Form["LeaveDateType"].ToString()); leaveData.LeaveDateType = Enums.GetDescription(leaveDateTypes); leaveData.LeaveDates = Request.Form["LeaveDates"].ToString().TrimEnd(','); leaveData.LeaveRemarks = Request.Form["leaveRemarks"].ToString(); leaveData.LeaveUser = UserInitiate.LoggedUser; DataSet resultSet = lvDb.InsertLeave(leaveData); string status = resultSet.Tables[0].Rows[0][0].ToString(); string statusMsg = resultSet.Tables[0].Rows[0][1].ToString(); if (status == "0") { Response.Redirect(Request.RawUrl); } else { Response.Redirect(string.Format("~/AppStatus.aspx?status={0}", statusMsg)); } }
private Table BindToTableLeaveID(int leaveID) { //Label1.Text = "(1 ตุลาคม " + (int.Parse(DropDownList1.SelectedValue) - 1) + " - 30 กันยายน " + DropDownList1.SelectedValue + ")"; Table table = new Table(); table.CssClass = "ps-table-1"; int budgetYear = int.Parse(DropDownList1.SelectedValue) - 543; OracleConnection.ClearAllPools(); using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING)) { con.Open(); const int maxCol = 2; { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = "สรุปข้อมูลการลาหยุดราชการ ขาดราชการ มาสาย ประจำปีงบประมาณ ประจำปีงบประมาณ พ.ศ. " + DropDownList1.SelectedValue; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = "มหาวิทยาลัยเทคโนโลยีราชมงคลตะวันออก"; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } TableHeaderRow rowXT = new TableHeaderRow(); TableHeaderCell cellXT = new TableHeaderCell(); { { cellXT.Text = loginPerson.FirstNameAndLastName; cellXT.ColumnSpan = maxCol; rowXT.Cells.Add(cellXT); } table.Rows.Add(rowXT); } { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = ""; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = "ข้อมูลการลา"; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } LeaveData leaveData = new LeaveData(); leaveData.Load(leaveID); { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "รหัสการลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.LeaveID; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "สถานะการลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.LeaveStatusName; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ประเภทการลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.LeaveTypeName; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "วันที่ข้อมูล"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.RequestDate.Value.ToLongDateString(); row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ชื่อผู้ลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.Person.FirstNameAndLastName; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ตำแหน่ง"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.Person.PS_WORK_POS_NAME; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ระดับ"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "" + leaveData.Person.PS_ADMIN_POS_NAME + leaveData.Person.AdminPositionNameExtra() == "ไม่มี" ? "" : leaveData.Person.AdminPositionNameExtra(); row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "สังกัด"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = Util.IsBlank(leaveData.Person.PS_WORK_DIVISION_NAME) ? leaveData.Person.PS_DIVISION_NAME : leaveData.Person.PS_WORK_DIVISION_NAME; row.Cells.Add(cell); } table.Rows.Add(row); } if (leaveData.LeaveTypeID == 4) { { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "วันลาพักผ่อนสะสม"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.RestSave + " วัน"; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "มีสิทธิลาประจำปีนี้อีก"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.RestLeft + " วัน"; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "รวม"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.RestTotal + " วัน"; row.Cells.Add(cell); } table.Rows.Add(row); } } if (leaveData.LeaveTypeID == 6) { { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "การอุปสมบท"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ชื่อวัด"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.TempleName; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "สถานที่"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.TempleLocation; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "อุปสมบทวันที่"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.OrdainDate.Value.ToLongDateString(); row.Cells.Add(cell); } table.Rows.Add(row); } } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "วันที่ลาล่าสุด"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.LastFromDate.HasValue ? leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน " : "ยังไม่เคยลา"; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "วันที่ลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน "; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "สถิติการลา"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / รวมครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน "; row.Cells.Add(cell); } table.Rows.Add(row); } if (leaveData.LeaveTypeID == 1 || leaveData.LeaveTypeID == 2 || leaveData.LeaveTypeID == 3) { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "เหตุผล"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.Reason; row.Cells.Add(cell); } table.Rows.Add(row); } if (leaveData.LeaveStatusID >= 4 && leaveData.LeaveStatusID <= 6) { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "เหตุผลที่ยกเลิก"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.CancelReason; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ติดต่อได้ที่"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveData.Contact; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "เบอร์โทรศัพท์"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = "'" + leaveData.Telephone; row.Cells.Add(cell); } table.Rows.Add(row); } { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = ""; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } { TableHeaderRow row = new TableHeaderRow(); { TableHeaderCell cell = new TableHeaderCell(); cell.Text = "ผู้อนุมัติการลา"; cell.ColumnSpan = maxCol; row.Cells.Add(cell); } table.Rows.Add(row); } List <LeaveBossData> leaveBossDataList = leaveData.LeaveBossDataList; for (int i = 0; i < leaveBossDataList.Count; i++) { LeaveBossData leaveBossData = leaveBossDataList[i]; { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ชื่อ"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveBossData.Person.FirstNameAndLastName; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ตำแหน่ง"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveBossData.Person.PS_WORK_POS_NAME; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "ระดับ"; row.Cells.Add(cell); } { TableCell cell = new TableCell(); cell.Text = leaveBossData.Person.PS_ADMIN_POS_NAME; row.Cells.Add(cell); } table.Rows.Add(row); } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "การอนุมัติ"; row.Cells.Add(cell); } string sss = ""; sss += "<div>" + leaveBossData.AllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.Allow == 1) { sss += "<div style='color:green;'>อนุญาต</div>"; } else { sss += "<div style='color:red;'>ไม่อนุญาต</div>"; } sss += "<div>" + leaveBossData.Comment + "</div>"; { TableCell cell = new TableCell(); cell.Text = sss; row.Cells.Add(cell); } table.Rows.Add(row); } if (leaveData.LeaveStatusID >= 4 && leaveData.LeaveStatusID <= 6) { { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = "การอนุมัติยกเลิก"; row.Cells.Add(cell); } string sss = ""; sss += "<div>" + leaveBossData.CancelAllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.CancelAllow == 1) { sss += "<div style='color:green;'>อนุญาต</div>"; } else { sss += "<div style='color:red;'>ไม่อนุญาต</div>"; } sss += "<div>" + leaveBossData.CancelComment + "</div>"; { TableCell cell = new TableCell(); cell.Text = sss; row.Cells.Add(cell); } table.Rows.Add(row); } } { TableRow row = new TableRow(); { TableCell cell = new TableCell(); cell.Text = ""; cell.ColumnSpan = 2; row.Cells.Add(cell); } table.Rows.Add(row); } } } return(table); }
protected void Page_Load(object sender, EventArgs e) { PersonnelSystem ps = PersonnelSystem.GetPersonnelSystem(this); Person loginPerson = ps.LoginPerson; int count = DatabaseManager.GetLeaveRequiredCountByCommander(loginPerson.PS_CITIZEN_ID); /* using (OleDbConnection con = new OleDbConnection(DatabaseManager.CONNECTION_STRING)) { * con.Open(); * using (OleDbCommand com = new OleDbCommand("SELECT COUNT(LEAVE_ID) FROM LEV_LEAVE WHERE CMD_HIGH_ID = '" + loginPerson.CitizenID + "' AND LEV_LEAVE.STATE_ID = 2", con)) { * using (OleDbDataReader reader = com.ExecuteReader()) { * while (reader.Read()) { * count = int.Parse(reader.GetValue(0).ToString()); * } * } * } * }*/ if (count == 0) { error_area.InnerHtml = "ไม่มีรายการที่ท่านต้องอนุมัติ"; } else { error_area.InnerHtml = "กรุณาเลือกรายการที่ต้องการอนุมัติ"; } error_area.Attributes["class"] = null; error_area.InnerHtml = ""; if (count > 0) { SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEV_DATA.LEAVE_ID รหัสการลา, (SELECT PS_FIRSTNAME || ' ' || PS_LASTNAME FROM PS_PERSON WHERE PS_CITIZEN_ID = LEV_DATA.PS_ID) ชื่อผู้ลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_DATA.LEAVE_TYPE_ID) ประเภทการลา, REQ_DATE วันที่ข้อมูล, (SELECT LEAVE_STATUS_NAME FROM LEV_STATUS WHERE LEAVE_STATUS_ID = LEV_DATA.LEAVE_STATUS_ID) สถานะ FROM LEV_DATA, LEV_BOSS_DATA WHERE LEAVE_STATUS_ID IN(1,4) AND LEV_DATA.LEAVE_ID = LEV_BOSS_DATA.LEAVE_ID AND LEV_DATA.BOSS_STATE = LEV_BOSS_DATA.STATE AND LEV_BOSS_DATA.CITIZEN_ID = '" + loginPerson.PS_CITIZEN_ID + "'"); GridView1.DataSource = sds; GridView1.DataBind(); Util.NormalizeGridViewDate(GridView1, 3); TableHeaderCell newHeader = new TableHeaderCell(); newHeader.Text = "เลือก"; GridView1.HeaderRow.Cells.Add(newHeader); GridView1.HeaderRow.Cells[0].Text = "<img src='Image/Small/ID.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[0].Text; GridView1.HeaderRow.Cells[1].Text = "<img src='Image/Small/person2.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[1].Text; GridView1.HeaderRow.Cells[2].Text = "<img src='Image/Small/list.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[2].Text; GridView1.HeaderRow.Cells[3].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[3].Text; GridView1.HeaderRow.Cells[4].Text = "<img src='Image/Small/question.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[4].Text; GridView1.HeaderRow.Cells[5].Text = "<img src='Image/Small/pointer.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[5].Text; for (int i = 0; i < GridView1.Rows.Count; ++i) { string id = GridView1.Rows[i].Cells[0].Text; LinkButton lbu = new LinkButton(); lbu.Text = "<img src='Image/Small/next.png'></img>"; lbu.CssClass = "ps-button"; lbu.Click += (e2, e3) => { LeaveData leaveData = new LeaveData(); leaveData.Load(int.Parse(id)); Session["LeaveData"] = leaveData; trPSBirthDate.Visible = false; trPSWorkInDate.Visible = false; trWifeName.Visible = false; trGBDate.Visible = false; trOrdained.Visible = false; trTempleName.Visible = false; trTempleLocation.Visible = false; trOrdainDate.Visible = false; trHujed.Visible = false; trReason.Visible = false; trContact.Visible = false; trPhone.Visible = false; trRestSave.Visible = false; trRestLeft.Visible = false; trRestTotal.Visible = false; trStatistic.Visible = false; //trCLOldComment.Visible = false; //trCLOldDate.Visible = false; //trCHOldComment.Visible = false; //trCHOldDate.Visible = false; trCancelReason.Visible = false; if (leaveData.LeaveTypeID == 1) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 2) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 3) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 4) { trRestSave.Visible = true; trRestLeft.Visible = true; trRestTotal.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 5) { trWifeName.Visible = true; trGBDate.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 6) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trOrdained.Visible = true; trTempleName.Visible = true; trTempleLocation.Visible = true; trOrdainDate.Visible = true; } else if (leaveData.LeaveTypeID == 7) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trHujed.Visible = true; } if (leaveData.LeaveStatusID == 2) { } else if (leaveData.LeaveStatusID == 4) { //trCLOldComment.Visible = true; //trCLOldDate.Visible = true; //trCHOldComment.Visible = true; //trCHOldDate.Visible = true; trCancelReason.Visible = true; } lbLeaveID.Text = leaveData.LeaveID.ToString(); lbLeaveTypeName.Text = leaveData.LeaveTypeName; lbReqDate.Text = leaveData.RequestDate.Value.ToLongDateString(); lbPSName.Text = leaveData.Person.PS_FIRSTNAME + " " + leaveData.Person.PS_LASTNAME; lbPSPos.Text = leaveData.Person.PS_WORK_POS_NAME; lbPSAPos.Text = leaveData.Person.PS_ADMIN_POS_NAME; if (Util.IsBlank(leaveData.Person.PS_WORK_DIVISION_ID)) { lbPSDept.Text = leaveData.Person.PS_DIVISION_NAME; } else { lbPSDept.Text = leaveData.Person.PS_WORK_DIVISION_NAME; } //if (leaveData.PS_BirthDate.HasValue) { lbPSBirthDate.Text = leaveData.Person.PS_BIRTHDAY_DATE.Value.ToLongDateString(); //} else { // lbPSBirthDate.Text = "-"; //} //if (leaveData.PS_WorkInDate.HasValue) { lbPSWorkInDate.Text = leaveData.Person.PS_INWORK_DATE.Value.ToLongDateString(); //} else { // lbPSWorkInDate.Text = "-"; // } lbRestSave.Text = leaveData.RestSave + " วัน"; lbRestLeft.Text = leaveData.RestLeft + " วัน"; lbRestTotal.Text = leaveData.RestTotal + " วัน"; lbWifeName.Text = leaveData.WifeFirstName + " " + leaveData.WifeLastName; if (leaveData.GiveBirthDate.HasValue) { lbGBDate.Text = leaveData.GiveBirthDate.Value.ToLongDateString(); } else { lbGBDate.Text = "-"; } lbOrdained.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; lbTempleName.Text = leaveData.TempleName; lbTempleLocation.Text = leaveData.TempleLocation; if (leaveData.OrdainDate.HasValue) { lbOrdainDate.Text = leaveData.OrdainDate.Value.ToLongDateString(); } else { lbOrdainDate.Text = "-"; } lbHujed.Text = leaveData.Hujed == 1 ? "เคย" : "ไม่เคย"; if (leaveData.FromDate.HasValue) { lbFTTDate.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน"; } else { lbFTTDate.Text = "ไม่เคยลา"; } lbStatistic.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / ลาครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน"; lbReason.Text = leaveData.Reason; lbContact.Text = leaveData.Contact; lbPhone.Text = leaveData.Telephone; if (leaveData.LastFromDate.HasValue) { lbLastFTTDate.Text = leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน"; } else { lbLastFTTDate.Text = "ไม่เคยลา"; } if (leaveData.DocterCertificationFileName != "") { divDrCer.InnerHtml = "<a href='Upload/Drcer/" + leaveData.DocterCertificationFileName + "'><img src='Upload/DrCer/" + leaveData.DocterCertificationFileName + "' style='width: 200px;' /></a>"; } /*lbCLComment.Text = ""; * for (int j = 0; j < leaveData.LeaveBossDataList.Count; j++) { * if(!leaveData.LeaveBossDataList[j].Allow.HasValue) { * continue; * } * LeaveBossData leaveBossData = leaveData.LeaveBossDataList[j]; * lbCLComment.Text += "<div style='color: #808080'>" + leaveBossData.Person.FirstNameAndLastName + " / " + leaveBossData.AllowDate.Value.ToLongDateString() + "</div><div style='margin-bottom: 10px;'> - " + leaveBossData.Comment + "</div>"; * }*/ { TableRow row = new TableRow(); TableCell cell2; Image image; tbBoss.Rows.Add(row); for (int j = 0; j < leaveData.BossStateMax; j++) { LeaveBossData leaveBossData = leaveData.LeaveBossDataList[j]; cell2 = new TableCell(); cell2.Style.Add("vertical-align", "top"); Table tb = new Table(); tb.CssClass = "ps-table-1"; tb.Style.Add("text-align", "left"); { TableRow tr; TableCell cell3; tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.ColumnSpan = 2; cell3.Style.Add("text-align", "center"); image = new Image(); image.CssClass = "ps-ms-main-drop-profile-pic"; string imagePath = DatabaseManager.GetPersonImageFileName(leaveBossData.CitizenID); if (imagePath != "") { image.Attributes["src"] = "Upload/PersonImage/" + imagePath; cell3.Controls.Add(image); } else { image.Attributes["src"] = "Image/no_image.png"; cell3.Controls.Add(image); } tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ชื่อ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.FirstNameAndLastName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ตำแหน่ง"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PS_WORK_POS_NAME; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ระดับ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PS_ADMIN_POS_NAME;// + "<br />" + leaveBossData.Person.AdminPositionNameExtra(); tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "การอนุมัติ"; tr.Cells.Add(cell3); cell3 = new TableCell(); if (leaveData.LeaveStatusID == 1) { if (leaveBossData.Allow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.AllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.Allow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.Comment + "</div>"; } } else if (leaveData.LeaveStatusID == 4) { if (leaveBossData.CancelAllow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.CancelAllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.CancelAllow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.CancelComment + "</div>"; } } tr.Cells.Add(cell3); } cell2.Controls.Add(tb); row.Cells.Add(cell2); } } lbCancelReason.Text = leaveData.CancelReason; /*if (leaveData.LeaveStatusID >= 1 && leaveData.LeaveStatusID <= 4) { * if(leaveData.CL_ID == null) { * lbCLComment.Text = "-"; * lbCLDate.Text = "-"; * } else { * lbCLComment.Text = leaveData.CL_Comment; * lbCLDate.Text = leaveData.CL_Date.Value.ToLongDateString(); * } * * } else if (leaveData.LeaveStatusID >= 5 && leaveData.LeaveStatusID <= 8) { * if(leaveData.CL_ID == null) { * lbCLOldComment.Text = "-"; * lbCLOldDate.Text = "-"; * lbCHOldComment.Text = leaveData.CH_Comment; * lbCHOldDate.Text = leaveData.CH_Date.Value.ToLongDateString(); * lbCancelReason.Text = leaveData.CancelReason; * lbCLComment.Text = "-"; * lbCLDate.Text = "-"; * } else { * lbCLOldComment.Text = leaveData.CL_Comment; * lbCLOldDate.Text = leaveData.CL_Date.Value.ToLongDateString(); * lbCHOldComment.Text = leaveData.CH_Comment; * lbCHOldDate.Text = leaveData.CH_Date.Value.ToLongDateString(); * lbCancelReason.Text = leaveData.CancelReason; * lbCLComment.Text = leaveData.CL_CancelComment; * lbCLDate.Text = leaveData.CL_CancelDate.Value.ToLongDateString(); * } * * }*/ MultiView1.ActiveViewIndex = 1; error_area.Attributes["class"] = null; error_area.InnerHtml = ""; }; TableCell cell = new TableCell(); cell.Controls.Add(lbu); GridView1.Rows[i].Cells.Add(cell); } lbNoData.Visible = false; } else { lbNoData.Visible = true; } }
public void ApplyLeave(LeaveData l) { db.LeaveDatas.Add(l); db.SaveChanges(); }
protected void Page_Load(object sender, EventArgs e) { PersonnelSystem ps = PersonnelSystem.GetPersonnelSystem(this); Person loginPerson = ps.LoginPerson; int count = 0;// DatabaseManager.GetLeaveRequiredCountByCommanderLow(loginPerson.CitizenID); ; /*using (OleDbConnection con = new OleDbConnection(DatabaseManager.CONNECTION_STRING)) { * con.Open(); * using (OleDbCommand com = new OleDbCommand("SELECT COUNT(LEV_MAIN.LEAVE_ID) FROM LEV_MAIN, LEV_FORM1 WHERE LEV_MAIN.LEAVE_ID = LEV_FORM1.LEAVE_ID AND CMD_LOW_ID = '" + loginPerson.CitizenID + "' AND LEAVE_STATE = 1", con)) { * using (OleDbDataReader reader = com.ExecuteReader()) { * while (reader.Read()) { * count = int.Parse(reader.GetValue(0).ToString()); * } * } * } * }*/ if (count == 0) { error_area.InnerHtml = "ไม่มีรายการที่ท่านต้องลงความเห็น"; } else { error_area.InnerHtml = "กรุณาเลือกรายการที่ต้องการลงความเห็น"; } //error_area.Attributes["class"] = "alert alert_info"; error_area.Attributes["class"] = null; error_area.InnerHtml = ""; if (count > 0) { SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEAVE_ID รหัสการลา, (SELECT PS_FIRSTNAME || ' ' || PS_LASTNAME FROM PS_PERSON WHERE PS_CITIZEN_ID = LEV_DATA.PS_ID) ชื่อผู้ลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_DATA.LEAVE_TYPE_ID) ประเภทการลา, REQ_DATE วันที่ข้อมูล, (SELECT LEAVE_STATUS_NAME FROM LEV_STATUS WHERE LEAVE_STATUS_ID = LEV_DATA.LEAVE_STATUS_ID) สถานะ FROM LEV_DATA WHERE LEAVE_STATUS_ID in(1,5) AND CL_ID = '" + loginPerson.PS_CITIZEN_ID + "'"); GridView1.DataSource = sds; GridView1.DataBind(); Util.NormalizeGridViewDate(GridView1, 3); TableHeaderCell newHeader = new TableHeaderCell(); newHeader.Text = "เลือก"; GridView1.HeaderRow.Cells.Add(newHeader); GridView1.HeaderRow.Cells[0].Text = "<img src='Image/Small/ID.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[0].Text; GridView1.HeaderRow.Cells[1].Text = "<img src='Image/Small/person2.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[1].Text; GridView1.HeaderRow.Cells[2].Text = "<img src='Image/Small/list.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[2].Text; GridView1.HeaderRow.Cells[3].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[3].Text; GridView1.HeaderRow.Cells[4].Text = "<img src='Image/Small/question.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[4].Text; GridView1.HeaderRow.Cells[5].Text = "<img src='Image/Small/pointer.png' class='icon_left'/>" + GridView1.HeaderRow.Cells[5].Text; for (int i = 0; i < GridView1.Rows.Count; ++i) { if (GridView1.Rows[i].Cells[4].Text == "1") { GridView1.Rows[i].Cells[4].Text = "ขอลา"; } if (GridView1.Rows[i].Cells[4].Text == "5") { GridView1.Rows[i].Cells[4].Text = "ยกเลิกลา"; } string id = GridView1.Rows[i].Cells[0].Text; LinkButton lbu = new LinkButton(); lbu.Text = "<img src='Image/Small/next.png'></img>"; lbu.CssClass = "ps-button"; lbu.Click += (e2, e3) => { LeaveData leaveData = new LeaveData(); leaveData.Load(int.Parse(id)); Session["LeaveData"] = leaveData; trPSBirthDate.Visible = false; trPSWorkInDate.Visible = false; trWifeName.Visible = false; trGBDate.Visible = false; trOrdained.Visible = false; trTempleName.Visible = false; trTempleLocation.Visible = false; trOrdainDate.Visible = false; trHujed.Visible = false; trReason.Visible = false; trContact.Visible = false; trPhone.Visible = false; trRestSave.Visible = false; trRestLeft.Visible = false; trRestTotal.Visible = false; trStatistic.Visible = false; trOldComment.Visible = false; trOldDate.Visible = false; trCancelReason.Visible = false; if (leaveData.LeaveTypeID == 1) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 2) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 3) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 4) { trRestSave.Visible = true; trRestLeft.Visible = true; trRestTotal.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 5) { trWifeName.Visible = true; trGBDate.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 6) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trOrdained.Visible = true; trTempleName.Visible = true; trTempleLocation.Visible = true; trOrdainDate.Visible = true; } else if (leaveData.LeaveTypeID == 7) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trHujed.Visible = true; } if (leaveData.LeaveStatusID == 1) { } else if (leaveData.LeaveStatusID == 5) { trOldComment.Visible = true; trOldDate.Visible = true; trCancelReason.Visible = true; } lbLeaveID.Text = leaveData.LeaveID.ToString(); lbLeaveTypeName.Text = leaveData.LeaveTypeName; lbReqDate.Text = leaveData.RequestDate.Value.ToLongDateString(); /* lbPSName.Text = leaveData.PS_Title + leaveData.PS_FirstName + " " + leaveData.PS_LastName; * lbPSPos.Text = leaveData.PS_Position; * lbPSAPos.Text = leaveData.PS_AdminPosition; * lbPSDept.Text = leaveData.PS_Department; * * if (leaveData.PS_BirthDate.HasValue) { * lbPSBirthDate.Text = leaveData.PS_BirthDate.Value.ToLongDateString(); * } else { * lbPSBirthDate.Text = "-"; * } * if (leaveData.PS_WorkInDate.HasValue) { * lbPSWorkInDate.Text = leaveData.PS_WorkInDate.Value.ToLongDateString(); * } else { * lbPSWorkInDate.Text = "-"; * }*/ lbRestSave.Text = leaveData.RestSave + " วัน"; lbRestLeft.Text = leaveData.RestLeft + " วัน"; lbRestTotal.Text = leaveData.RestTotal + " วัน"; lbWifeName.Text = leaveData.WifeFirstName + " " + leaveData.WifeLastName; if (leaveData.GiveBirthDate.HasValue) { lbGBDate.Text = leaveData.GiveBirthDate.Value.ToLongDateString(); } else { lbGBDate.Text = "-"; } lbOrdained.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; lbTempleName.Text = leaveData.TempleName; lbTempleLocation.Text = leaveData.TempleLocation; if (leaveData.OrdainDate.HasValue) { lbOrdainDate.Text = leaveData.OrdainDate.Value.ToLongDateString(); } else { lbOrdainDate.Text = "-"; } lbHujed.Text = leaveData.Hujed == 1 ? "เคย" : "ไม่เคย"; if (leaveData.FromDate.HasValue) { lbFTTDate.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน"; } else { lbFTTDate.Text = "ไม่เคยลา"; } lbStatistic.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / ลาครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน"; lbReason.Text = leaveData.Reason; lbContact.Text = leaveData.Contact; lbPhone.Text = leaveData.Telephone; if (leaveData.LastFromDate.HasValue) { lbLastFTTDate.Text = leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน"; } else { lbLastFTTDate.Text = "ไม่เคยลา"; } /* if(leaveData.LeaveStatusID >= 5 && leaveData.LeaveStatusID <= 8) { * lbOldComment.Text = leaveData.CL_Comment; * lbOldDate.Text = leaveData.CL_Date.Value.ToLongDateString(); * lbCancelReason.Text = leaveData.CancelReason; * }*/ if (leaveData.DocterCertificationFileName != "") { divDrCer.InnerHtml = "<a href='Upload/Drcer/" + leaveData.DocterCertificationFileName + "'><img src='Upload/DrCer/" + leaveData.DocterCertificationFileName + "' style='width: 200px;' /></a>"; } MultiView1.ActiveViewIndex = 1; error_area.Attributes["class"] = null; error_area.InnerHtml = ""; }; TableCell cell = new TableCell(); cell.Controls.Add(lbu); GridView1.Rows[i].Cells.Add(cell); } } }
public LeaveHelper(string CS_Name) { data = new LeaveData(CS_Name); studentData = new StudentData(CS_Name); }
/*protected void tbUsername_TextChanged(object sender, EventArgs e) * { * OracleConnection.ClearAllPools(); * using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING)) * { * con.Open(); * using (OracleCommand com = new OracleCommand("SELECT ST_LOGIN_ID FROM PS_PERSON WHERE PS_CITIZEN_ID ='" + tbUsername.Text + "'", con)) * { * using (OracleDataReader reader = com.ExecuteReader()) * { * while (reader.Read()) * { * if (!reader.IsDBNull(0)) * { * int Login = reader.GetInt32(0); * * if (tbUsername.Text.Length == 13) * { * if (Login == 0) * { * LabelTop.Text = "รหัสบัตรประชาชนดังกล่าวเป็นการล็อคอินครั้งแรก โปรดยืนยันตัวตน ด้วยการใส่รหัสผ่านเป็นวันเกิด"; * ScriptManager.GetCurrent(this.Page).SetFocus(this.tbPassword); * } * if (Login == 1) * { * LabelTop.Text = ""; * ScriptManager.GetCurrent(this.Page).SetFocus(this.tbPassword); * } * } * * } * * } * } * } * using (OracleCommand com2 = new OracleCommand("SELECT COUNT(*) FROM PS_PERSON WHERE PS_CITIZEN_ID ='" + tbUsername.Text + "'", con)) * { * using (OracleDataReader reader2 = com2.ExecuteReader()) * { * while (reader2.Read()) * { * if (reader2.GetInt32(0) == 0) * { * LabelBottom.Text = "ไม่พบผู้ใช้งาน!"; * ScriptManager.GetCurrent(this.Page).SetFocus(this.tbUsername); * return; * } * else * { * LabelBottom.Text = ""; * ScriptManager.GetCurrent(this.Page).SetFocus(this.tbPassword); * } * } * } * } * } * * }*/ protected void btnLogin_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(tbUsername.Text) || string.IsNullOrEmpty(tbPassword.Text)) { LabelBottom.Text = "กรุณากรอกรหัสประชาชนและรหัสผ่าน"; return; } int count = DatabaseManager.ExecuteInt("SELECT count(*) FROM PS_PERSON WHERE PS_CITIZEN_ID = '" + tbUsername.Text + "'"); if (count == 0) { LabelBottom.Text = "ไม่พบผู้ใช้งาน!"; return; } OracleConnection.ClearAllPools(); using (OracleConnection con = new OracleConnection(DatabaseManager.CONNECTION_STRING)) { con.Open(); using (OracleCommand com = new OracleCommand("SELECT ST_LOGIN_ID FROM PS_PERSON WHERE PS_CITIZEN_ID ='" + tbUsername.Text + "'", con)) { using (OracleDataReader reader = com.ExecuteReader()) { while (reader.Read()) { if (!reader.IsDBNull(0)) { int Login = reader.GetInt32(0); if (tbUsername.Text.Length == 13) { if (Login == 0) { LabelTop.Text = "รหัสบัตรประชาชนดังกล่าวเป็นการล็อคอินครั้งแรก โปรดยืนยันตัวตน ด้วยการใส่รหัสผ่านเป็นวันเกิด รูปแบบ(01 ม.ค. 2500)"; ScriptManager.GetCurrent(this.Page).SetFocus(this.tbPassword); } if (Login == 1) { LabelTop.Text = ""; ScriptManager.GetCurrent(this.Page).SetFocus(this.tbPassword); } } } } } } int First = 0; int NotFirst = 1; using (OracleCommand com = new OracleCommand("SELECT ST_LOGIN_ID,PS_PASSWORD FROM PS_PERSON WHERE PS_CITIZEN_ID ='" + tbUsername.Text + "'", con)) { using (OracleDataReader reader = com.ExecuteReader()) { while (reader.Read()) { string source = tbPassword.Text; using (MD5 md5Hash = MD5.Create()) { string hash = GetMd5Hash(md5Hash, source); if (!reader.IsDBNull(0)) { if (reader.GetInt32(0) == First) { if (!Util.IsDateValid(tbPassword.Text)) { LabelBottom.Text = "รหัสผ่านไม่ถูกต้อง!"; return; } if (DatabaseManager.ValidatePasswordFirst(tbUsername.Text, Util.ToDateTimeOracle(Server.UrlDecode(tbPassword.Text)))) { PersonnelSystem ps = new PersonnelSystem(); ps.LoginPerson = DatabaseManager.GetPerson(tbUsername.Text); Session["PersonnelSystem"] = ps; Response.Redirect("ChangePassword.aspx"); } else { LabelBottom.Text = "รหัสผ่านไม่ถูกต้อง!"; return; } } if (reader.GetInt32(0) == NotFirst) { if (reader.GetString(1) == hash.ToString()) { PersonnelSystem ps = new PersonnelSystem(); ps.LoginPerson = DatabaseManager.GetPerson(tbUsername.Text); // // if (DatabaseManager.ExecuteInt("SELECT COUNT(*) FROM LEV_CLAIM WHERE PS_CITIZEN_ID = '" + ps.LoginPerson.PS_CITIZEN_ID + "' AND YEAR = " + Util.BudgetYear()) == 0) { using (OracleCommand com3 = new OracleCommand("INSERT INTO LEV_CLAIM (LEAVE_CLAIM_ID, PS_CITIZEN_ID, YEAR, SICK_NOW, SICK_REQ, BUSINESS_NOW, BUSINESS_REQ, GB_NOW, GB_REQ, REST_NOW, REST_REQ, REST_SAVE, REST_SAVE_FIX, REST_THIS, REST_THIS_FIX, REST_MAX, HGB_NOW, HGB_REQ, ORDAIN_NOW, ORDAIN_REQ, HUJ_NOW, HUJ_REQ, SICK_MAX, BUSINESS_MAX, HUJ_MAX, ORDAIN_MAX) VALUES (SEQ_LEV_CLAIM_ID.NEXTVAL, :PS_CITIZEN_ID, :YEAR, :SICK_NOW, :SICK_REQ, :BUSINESS_NOW, :BUSINESS_REQ, :GB_NOW, :GB_REQ, :REST_NOW, :REST_REQ, :REST_SAVE, :REST_SAVE_FIX, :REST_THIS, :REST_THIS_FIX, :REST_MAX, :HGB_NOW, :HGB_REQ, :ORDAIN_NOW, :ORDAIN_REQ, :HUJ_NOW, :HUJ_REQ, :SICK_MAX, :BUSINESS_MAX, :HUJ_MAX, :ORDAIN_MAX)", con)) { com3.Parameters.AddWithValue("PS_CITIZEN_ID", ps.LoginPerson.PS_CITIZEN_ID); com3.Parameters.AddWithValue("YEAR", Util.BudgetYear()); int v1 = 0; int v2 = 10; int v60 = 60; int v45 = 45; int v120 = 120; com3.Parameters.AddWithValue("SICK_NOW", v1); com3.Parameters.AddWithValue("SICK_REQ", v1); com3.Parameters.AddWithValue("BUSINESS_NOW", v1); com3.Parameters.AddWithValue("BUSINESS_REQ", v1); com3.Parameters.AddWithValue("GB_NOW", v1); com3.Parameters.AddWithValue("GB_REQ", v1); com3.Parameters.AddWithValue("REST_NOW", v1); com3.Parameters.AddWithValue("REST_REQ", v1); com3.Parameters.AddWithValue("REST_SAVE", v1); com3.Parameters.AddWithValue("REST_SAVE_FIX", v1); com3.Parameters.AddWithValue("REST_THIS", v2); com3.Parameters.AddWithValue("REST_THIS_FIX", v2); com3.Parameters.AddWithValue("REST_MAX", v2); com3.Parameters.AddWithValue("HGB_NOW", v1); com3.Parameters.AddWithValue("HGB_REQ", v1); com3.Parameters.AddWithValue("ORDAIN_NOW", v1); com3.Parameters.AddWithValue("ORDAIN_REQ", v1); com3.Parameters.AddWithValue("HUJ_NOW", v1); com3.Parameters.AddWithValue("HUJ_REQ", v1); com3.Parameters.AddWithValue("SICK_MAX", v60); com3.Parameters.AddWithValue("BUSINESS_MAX", v45); com3.Parameters.AddWithValue("HUJ_MAX", v120); com3.Parameters.AddWithValue("ORDAIN_MAX", v120); com3.ExecuteNonQuery(); } } // using (OracleCommand com4 = new OracleCommand("SELECT LEAVE_ID FROM LEV_DATA WHERE CURRENT_DATE >= FROM_DATE AND LEAVE_TYPE_ID IN(2,4,6,7) AND LEAVE_STATUS_ID = 1", con)) { using (OracleDataReader reader4 = com.ExecuteReader()) { while (reader4.Read()) { int leaveID = reader4.GetInt32(0); LeaveData leaveData = new LeaveData(); leaveData.Load(leaveID); leaveData.ExecuteCancelBySystem(); } } } using (OracleCommand com5 = new OracleCommand("SELECT LEAVE_ID FROM LEV_DATA WHERE LEAVE_STATUS_ID = 1 AND TRUNC(CURRENT_DATE - REQ_DATE, 0) >= 3", con)) { using (OracleDataReader reader5 = com5.ExecuteReader()) { while (reader5.Read()) { int leaveID = reader5.GetInt32(0); LeaveData leaveData = new LeaveData(); leaveData.Load(leaveID); leaveData.ExecuteCancelBySystem(); } } } Session["PersonnelSystem"] = ps; Response.Redirect("Default.aspx"); } else { LabelBottom.Text = "รหัสผ่านไม่ถูกต้อง!"; return; } } } } } } } } }
protected void Page_Load(object sender, EventArgs e) { /*if (!IsPostBack) { * ChangeNotification("info", "กรุณากรอกข้อมูล"); * }*/ PersonnelSystem ps = PersonnelSystem.GetPersonnelSystem(this); UOC_STAFF loginPerson = ps.LoginPerson; //------ { SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEAVE_ID รหัสการลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_DATA.LEAVE_TYPE_ID) ประเภทการลา, REQ_DATE วันที่ข้อมูล, FROM_DATE จากวันที่, TO_DATE ถึงวันที่, TOTAL_DAY รวมวัน FROM LEV_DATA WHERE LEAVE_STATUS_ID = 1 AND PS_ID = '" + loginPerson.CITIZEN_ID + "' ORDER BY LEAVE_ID DESC"); gvLeaveProgress.DataSource = sds; gvLeaveProgress.DataBind(); if (gvLeaveProgress.Rows.Count > 0) { lbLeaveProgress.Visible = false; TableHeaderCell headerCell = new TableHeaderCell(); headerCell.Text = "เลือก"; gvLeaveProgress.HeaderRow.Cells.Add(headerCell); gvLeaveProgress.HeaderRow.Cells[0].Text = "<img src='Image/Small/ID.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[0].Text; gvLeaveProgress.HeaderRow.Cells[1].Text = "<img src='Image/Small/list.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[1].Text; gvLeaveProgress.HeaderRow.Cells[2].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[2].Text; gvLeaveProgress.HeaderRow.Cells[3].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[3].Text; gvLeaveProgress.HeaderRow.Cells[4].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[4].Text; gvLeaveProgress.HeaderRow.Cells[6].Text = "<img src='Image/Small/pointer.png' class='icon_left'/>" + gvLeaveProgress.HeaderRow.Cells[6].Text; for (int i = 0; i < gvLeaveProgress.Rows.Count; ++i) { string ID = gvLeaveProgress.Rows[i].Cells[0].Text; TableCell cell = new TableCell(); LinkButton btn = new LinkButton(); btn.CssClass = "ps-button"; btn.Text = "<img src='Image/Small/next.png'></img>"; btn.Click += (e2, e3) => { lbuCancelFinish.Visible = false; lbuCancelProgressFinish.Visible = true; trCancelReason.Visible = false; LeaveData leaveData = new LeaveData(); leaveData.Load(int.Parse(ID)); trPSBirthDate.Visible = false; trPSWorkInDate.Visible = false; trWifeName.Visible = false; trGBDate.Visible = false; trOrdained.Visible = false; trTempleName.Visible = false; trTempleLocation.Visible = false; trOrdainDate.Visible = false; trHujed.Visible = false; trReason.Visible = false; trContact.Visible = false; trPhone.Visible = false; trRestSave.Visible = false; trRestLeft.Visible = false; trRestTotal.Visible = false; trStatistic.Visible = false; if (leaveData.LeaveTypeID == 1) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 2) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 3) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 4) { trRestSave.Visible = true; trRestLeft.Visible = true; trRestTotal.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 5) { trWifeName.Visible = true; trGBDate.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 6) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trOrdained.Visible = true; trTempleName.Visible = true; trTempleLocation.Visible = true; trOrdainDate.Visible = true; } else if (leaveData.LeaveTypeID == 7) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trHujed.Visible = true; } lbLeaveID.Text = leaveData.LeaveID.ToString(); lbLeaveTypeName.Text = leaveData.LeaveTypeName; lbReqDate.Text = leaveData.RequestDate.Value.ToLongDateString(); lbPSName.Text = leaveData.Person.FirstName + " " + leaveData.Person.LastName; lbPSPos.Text = leaveData.Person.PositionWorkName; lbPSAPos.Text = leaveData.Person.AdminPositionName; if (Util.IsBlank(leaveData.Person.WorkDivisionID)) { lbPSDept.Text = leaveData.Person.DivisionName; } else { lbPSDept.Text = leaveData.Person.WorkDivisionName; } lbPSBirthDate.Text = leaveData.Person.BIRTHDAY.Value.ToLongDateString(); lbPSWorkInDate.Text = leaveData.Person.DATE_INWORK.Value.ToLongDateString(); lbRestSave.Text = leaveData.RestSave + " วัน"; lbRestLeft.Text = leaveData.RestLeft + " วัน"; lbRestTotal.Text = leaveData.RestTotal + " วัน"; lbWifeName.Text = leaveData.WifeFirstName + " " + leaveData.WifeLastName; if (leaveData.GiveBirthDate.HasValue) { lbGBDate.Text = leaveData.GiveBirthDate.Value.ToLongDateString(); } else { lbGBDate.Text = "-"; } lbOrdained.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; lbTempleName.Text = leaveData.TempleName; lbTempleLocation.Text = leaveData.TempleLocation; if (leaveData.OrdainDate.HasValue) { lbOrdainDate.Text = leaveData.OrdainDate.Value.ToLongDateString(); } else { lbOrdainDate.Text = "-"; } lbHujed.Text = leaveData.Hujed == 1 ? "เคย" : "ไม่เคย"; if (leaveData.FromDate.HasValue) { lbFTTDate.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน"; } else { lbFTTDate.Text = "ไม่เคยลา"; } lbStatistic.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / ลาครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน"; lbReason.Text = leaveData.Reason; lbContact.Text = leaveData.Contact; lbPhone.Text = leaveData.Telephone; if (leaveData.LastFromDate.HasValue) { lbLastFTTDate.Text = leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน"; } else { lbLastFTTDate.Text = "ไม่เคยลา"; } if (leaveData.DocterCertificationFileName != "") { divDrCer.InnerHtml = "<a href='Upload/Drcer/" + leaveData.DocterCertificationFileName + "'><img src='Upload/DrCer/" + leaveData.DocterCertificationFileName + "' style='width: 200px;' /></a>"; } { TableRow row = new TableRow(); TableCell cell2; Image image; tbBoss.Rows.Add(row); for (int j = 0; j < leaveData.BossStateMax; j++) { LeaveBossData leaveBossData = leaveData.LeaveBossDataList[j]; cell2 = new TableCell(); cell2.Style.Add("vertical-align", "top"); Table tb = new Table(); tb.CssClass = "ps-table-1"; tb.Style.Add("text-align", "left"); { TableRow tr; TableCell cell3; tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.ColumnSpan = 2; cell3.Style.Add("text-align", "center"); image = new Image(); image.CssClass = "ps-ms-main-drop-profile-pic"; string imagePath = DatabaseManager.GetPersonImageFileName(leaveBossData.CitizenID); if (imagePath != "") { image.Attributes["src"] = "Upload/PersonImage/" + imagePath; cell3.Controls.Add(image); } tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ชื่อ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.FirstNameAndLastName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ตำแหน่ง"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PositionWorkName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ระดับ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.AdminPositionName;// + "<br />" + leaveBossData.Person.AdminPositionNameExtra(); tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "การอนุมัติ"; tr.Cells.Add(cell3); cell3 = new TableCell(); if (leaveBossData.Allow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.AllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.Allow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.Comment + "</div>"; } tr.Cells.Add(cell3); } cell2.Controls.Add(tb); row.Cells.Add(cell2); } } Session["LeaveData"] = leaveData; MV1.ActiveViewIndex = 1; //Response.Redirect("ViewLeaveForm.aspx?Form=1&LeaveID=" + ID); }; cell.Controls.Add(btn); gvLeaveProgress.Rows[i].Cells.Add(cell); } Util.NormalizeGridViewDate(gvLeaveProgress, 2); Util.NormalizeGridViewDate(gvLeaveProgress, 3); Util.NormalizeGridViewDate(gvLeaveProgress, 4); } else { lbLeaveProgress.Visible = true; } } //-------- { SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEAVE_ID รหัสการลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_DATA.LEAVE_TYPE_ID) ประเภทการลา, REQ_DATE วันที่ข้อมูล, FROM_DATE จากวันที่, TO_DATE ถึงวันที่, TOTAL_DAY รวมวัน FROM LEV_DATA WHERE LEAVE_STATUS_ID = 3 AND PS_ID = '" + loginPerson.CITIZEN_ID + "' AND V_ALLOW = 1 AND CEIL(FROM_DATE - CURRENT_DATE) >= 3 ORDER BY LEAVE_ID DESC"); gvLeave.DataSource = sds; gvLeave.DataBind(); if (gvLeave.Rows.Count > 0) { lbLeave.Visible = false; TableHeaderCell headerCell = new TableHeaderCell(); headerCell.Text = "เลือก"; gvLeave.HeaderRow.Cells.Add(headerCell); gvLeave.HeaderRow.Cells[0].Text = "<img src='Image/Small/ID.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[0].Text; gvLeave.HeaderRow.Cells[1].Text = "<img src='Image/Small/list.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[1].Text; gvLeave.HeaderRow.Cells[2].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[2].Text; gvLeave.HeaderRow.Cells[3].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[3].Text; gvLeave.HeaderRow.Cells[4].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[4].Text; gvLeave.HeaderRow.Cells[6].Text = "<img src='Image/Small/pointer.png' class='icon_left'/>" + gvLeave.HeaderRow.Cells[6].Text; for (int i = 0; i < gvLeave.Rows.Count; ++i) { string ID = gvLeave.Rows[i].Cells[0].Text; TableCell cell = new TableCell(); LinkButton btn = new LinkButton(); btn.CssClass = "ps-button"; btn.Text = "<img src='Image/Small/next.png'></img>"; btn.Click += (e2, e3) => { lbuCancelFinish.Visible = true; lbuCancelProgressFinish.Visible = false; trCancelReason.Visible = true; LeaveData leaveData = new LeaveData(); leaveData.Load(int.Parse(ID)); trPSBirthDate.Visible = false; trPSWorkInDate.Visible = false; trWifeName.Visible = false; trGBDate.Visible = false; trOrdained.Visible = false; trTempleName.Visible = false; trTempleLocation.Visible = false; trOrdainDate.Visible = false; trHujed.Visible = false; trReason.Visible = false; trContact.Visible = false; trPhone.Visible = false; trRestSave.Visible = false; trRestLeft.Visible = false; trRestTotal.Visible = false; trStatistic.Visible = false; if (leaveData.LeaveTypeID == 1) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 2) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 3) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 4) { trRestSave.Visible = true; trRestLeft.Visible = true; trRestTotal.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 5) { trWifeName.Visible = true; trGBDate.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 6) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trOrdained.Visible = true; trTempleName.Visible = true; trTempleLocation.Visible = true; trOrdainDate.Visible = true; } else if (leaveData.LeaveTypeID == 7) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trHujed.Visible = true; } lbLeaveID.Text = leaveData.LeaveID.ToString(); lbLeaveTypeName.Text = leaveData.LeaveTypeName; lbReqDate.Text = leaveData.RequestDate.Value.ToLongDateString(); lbPSName.Text = leaveData.Person.FirstName + " " + leaveData.Person.LastName; lbPSPos.Text = leaveData.Person.PositionWorkName; lbPSAPos.Text = leaveData.Person.AdminPositionName; if (Util.IsBlank(leaveData.Person.WorkDivisionID)) { lbPSDept.Text = leaveData.Person.DivisionName; } else { lbPSDept.Text = leaveData.Person.WorkDivisionName; } lbPSBirthDate.Text = leaveData.Person.BIRTHDAY.Value.ToLongDateString(); lbPSWorkInDate.Text = leaveData.Person.DATE_INWORK.Value.ToLongDateString(); lbRestSave.Text = leaveData.RestSave + " วัน"; lbRestLeft.Text = leaveData.RestLeft + " วัน"; lbRestTotal.Text = leaveData.RestTotal + " วัน"; lbWifeName.Text = leaveData.WifeFirstName + " " + leaveData.WifeLastName; if (leaveData.GiveBirthDate.HasValue) { lbGBDate.Text = leaveData.GiveBirthDate.Value.ToLongDateString(); } else { lbGBDate.Text = "-"; } lbOrdained.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; lbTempleName.Text = leaveData.TempleName; lbTempleLocation.Text = leaveData.TempleLocation; if (leaveData.OrdainDate.HasValue) { lbOrdainDate.Text = leaveData.OrdainDate.Value.ToLongDateString(); } else { lbOrdainDate.Text = "-"; } lbHujed.Text = leaveData.Hujed == 1 ? "เคย" : "ไม่เคย"; if (leaveData.FromDate.HasValue) { lbFTTDate.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน"; } else { lbFTTDate.Text = "ไม่เคยลา"; } lbStatistic.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / ลาครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน"; lbReason.Text = leaveData.Reason; lbContact.Text = leaveData.Contact; lbPhone.Text = leaveData.Telephone; if (leaveData.LastFromDate.HasValue) { lbLastFTTDate.Text = leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน"; } else { lbLastFTTDate.Text = "ไม่เคยลา"; } if (leaveData.DocterCertificationFileName != "") { divDrCer.InnerHtml = "<a href='Upload/Drcer/" + leaveData.DocterCertificationFileName + "'><img src='Upload/DrCer/" + leaveData.DocterCertificationFileName + "' style='width: 200px;' /></a>"; } { TableRow row = new TableRow(); TableCell cell2; Image image; tbBoss.Rows.Add(row); for (int j = 0; j < leaveData.BossStateMax; j++) { LeaveBossData leaveBossData = leaveData.LeaveBossDataList[j]; cell2 = new TableCell(); cell2.Style.Add("vertical-align", "top"); Table tb = new Table(); tb.CssClass = "ps-table-1"; tb.Style.Add("text-align", "left"); { TableRow tr; TableCell cell3; tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.ColumnSpan = 2; cell3.Style.Add("text-align", "center"); image = new Image(); image.CssClass = "ps-ms-main-drop-profile-pic"; string imagePath = DatabaseManager.GetPersonImageFileName(leaveBossData.CitizenID); if (imagePath != "") { image.Attributes["src"] = "Upload/PersonImage/" + imagePath; cell3.Controls.Add(image); } tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ชื่อ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.FirstNameAndLastName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ตำแหน่ง"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PositionWorkName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ระดับ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.AdminPositionName;// + "<br />" + leaveBossData.Person.AdminPositionNameExtra(); tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "การอนุมัติ"; tr.Cells.Add(cell3); cell3 = new TableCell(); if (leaveBossData.Allow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.AllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.Allow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.Comment + "</div>"; } tr.Cells.Add(cell3); } cell2.Controls.Add(tb); row.Cells.Add(cell2); } } Session["LeaveData"] = leaveData; MV1.ActiveViewIndex = 1; //Response.Redirect("ViewLeaveForm.aspx?Form=1&LeaveID=" + ID); }; cell.Controls.Add(btn); gvLeave.Rows[i].Cells.Add(cell); } Util.NormalizeGridViewDate(gvLeave, 2); Util.NormalizeGridViewDate(gvLeave, 3); Util.NormalizeGridViewDate(gvLeave, 4); } else { lbLeave.Visible = true; } } }
private void btnImport_Click(object sender, EventArgs e) { txtYearMT.Enabled = false; btnBrowse.Enabled = false; btnImport.Enabled = false; btnPreview.Enabled = false; if (grd_view1.DataRowCount <= 0) { MessageBox.Show("No Rows to Upload", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Cursor.Current = Cursors.WaitCursor; DataTable dtMaterial = new DataTable(); DataTable sortedDT = new DataTable(); try { foreach (GridColumn column in grd_view1.VisibleColumns) { if (column.FieldName != string.Empty) { dtMaterial.Columns.Add(column.FieldName, column.ColumnType); } } for (int i = 0; i < grd_view1.DataRowCount; i++) { DataRow row = dtMaterial.NewRow(); foreach (GridColumn column in grd_view1.VisibleColumns) { row[column.FieldName] = grd_view1.GetRowCellValue(i, column); } dtMaterial.Rows.Add(row); } DataView dv = dtMaterial.DefaultView; dv.Sort = "EmpUnqID asc"; sortedDT = dv.ToTable(); using (SqlConnection cn = new SqlConnection(Utils.Helper.constr)) { DateTime StartDt = new DateTime(), EndDt = new DateTime(); string sql = string.Empty; string tYearMt = txtYearMT.DateTime.ToString("yyyyMM"); string stdt = Utils.Helper.GetDescription("Select CAL_MthStart From V_CAL0815 where Cal_Date ='" + txtYearMT.DateTime.ToString("yyyy-MM-dd") + "'", Utils.Helper.constr); string endt = Utils.Helper.GetDescription("Select CAL_MthEnd From V_CAL0815 where Cal_Date ='" + txtYearMT.DateTime.ToString("yyyy-MM-dd") + "'", Utils.Helper.constr); StartDt = Convert.ToDateTime(stdt); EndDt = Convert.ToDateTime(endt); foreach (DataRow dr in sortedDT.Rows) { if (cn.State == ConnectionState.Open) { cn.Close(); } bool ProcessFlg = chkProcessFlg.Checked; cn.Open(); bool brkflg = false; string tEmpUnqID = dr["EmpUnqID"].ToString(); string tCompCode = Utils.Helper.GetDescription("Select CompCode From MastEmp where EmpUnqID ='" + tEmpUnqID + "'", Utils.Helper.constr); clsEmp Emp = new clsEmp(); Emp.GetEmpDetails(tCompCode, tEmpUnqID); if (!Emp.Active) { dr["Remarks"] = "Invalid/InActive Employee.."; continue; } if (!Globals.GetWrkGrpRights(GFormID, Emp.WrkGrp, Emp.EmpUnqID)) { dr["Remarks"] = "you are not authorised.."; continue; } List <int> woidx = new List <int>(); #region Chk_ValidShift for (int i = 1; i <= EndDt.Day; i++) { string fldnm = "D" + i.ToString("00"); string fldval = dr[fldnm].ToString().Trim().ToUpper(); if (fldval != "WO") { if (!Globals.G_ShiftList.Contains(fldval)) { dr["Remarks"] = dr["Remarks"].ToString() + " Invalid Shift.."; brkflg = true; break; } } else { woidx.Add(i); } if (fldval.Trim() == string.Empty) { dr["Remarks"] = dr["Remarks"].ToString() + " Invalid Shift.."; brkflg = true; break; } } if (woidx.Count == 0) { dr["Remarks"] = dr["Remarks"].ToString() + " No Week of has been defined.."; brkflg = true; } if (brkflg) { continue; } #region Check_WO_Order //int firstWOon = woidx.First(); //int tchk = 0; //for (int i = 1; i <= woidx.Count - 1; i++) //{ // tchk = (7 * i) + firstWOon; // if(woidx.ElementAt(i) != tchk) // { // dr["Remarks"] = dr["Remarks"].ToString() + string.Format("{0} WeekOff is not in correct order..",i); // //brkflg = true; // break; // } //} //if (brkflg) //{ // continue; //} #endregion #endregion SqlTransaction trn = cn.BeginTransaction("ShiftSch-" + Emp.EmpUnqID); SqlCommand cmd = new SqlCommand(); #region Chk_ShiftSchedule_Rec try { int cnt = Convert.ToInt32(Utils.Helper.GetDescription("Select Count(*) from MastShiftSchedule where EmpUnqID = '" + tEmpUnqID + "' And YearMt ='" + tYearMt + "'", Utils.Helper.constr)); if (cnt == 0) { sql = "Insert into MastShiftSchedule (YearMt,EmpUnqID,AddDt,AddId) Values ('" + tYearMt + "','" + tEmpUnqID + "',GetDate(),'" + Utils.User.GUserID + "')"; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); } else { sql = "insert into MastShiftScheduleHistory ( [YearMt],[EmpUnqID], " + " [D01],[D02],[D03],[D04],[D05],[D06],[D07],[D08],[D09],[D10]," + " [D11],[D12],[D13],[D14],[D15],[D16],[D17],[D18],[D19],[D20],[D21], " + " [D22],[D23],[D24],[D25],[D26],[D27],[D28],[D29],[D30],[D31],[ADDID], " + " [ADDDT],[UPDID],[UPDDT]) " + " Select " + " [YearMt],[EmpUnqID]," + " [D01],[D02],[D03],[D04],[D05],[D06],[D07],[D08],[D09],[D10]," + " [D11],[D12],[D13],[D14],[D15],[D16],[D17],[D18],[D19],[D20],[D21], " + " [D22],[D23],[D24],[D25],[D26],[D27],[D28],[D29],[D30],[D31],[ADDID]," + " [ADDDT],[UPDID],[UPDDT] from MastShiftSchedule " + " where YearMt = '" + tYearMt + "' " + " and EmpUnqID = '" + tEmpUnqID + "' "; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); sql = "Update MastShiftSchedule Set UpdDt = GetDate() , UpdID = '" + Utils.User.GUserID + "' Where YearMt = '" + tYearMt + "' And EmpUnqID ='" + tEmpUnqID + "'"; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); } } catch (Exception ex) { brkflg = true; dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); } if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } #endregion #region Get_IFAnyLeavePosted sql = "Select * from LeaveEntry Where " + " compcode = '" + Emp.CompCode + "'" + " and WrkGrp ='" + Emp.WrkGrp + "'" + " And tYear ='" + tYearMt.Substring(0, 4) + "'" + " And EmpUnqID='" + tEmpUnqID + "'" + " And ( FromDt between '" + StartDt.ToString("yyyy-MM-dd") + "' And '" + EndDt.ToString("yyyy-MM-dd") + "' " + " OR ToDt Between '" + StartDt.ToString("yyyy-MM-dd") + "' And '" + EndDt.ToString("yyyy-MM-dd") + "' " + " ) Order by FromDt "; DataSet dsLeave = Utils.Helper.GetData(sql, Utils.Helper.constr); List <LeaveData> leave = new List <LeaveData>(); bool hasRows = dsLeave.Tables.Cast <DataTable>().Any(table => table.Rows.Count != 0); if (hasRows) { foreach (DataRow drl in dsLeave.Tables[0].Rows) { LeaveData t = new LeaveData(); t.FromDt = Convert.ToDateTime(drl["FromDt"]); t.ToDt = ((Convert.ToDateTime(drl["ToDt"]) > EndDt) ? EndDt : Convert.ToDateTime(drl["ToDt"])); t.LeaveTyp = drl["LeaveTyp"].ToString(); leave.Add(t); } } #endregion #region Upd_ShiftSchedule_AttdData string ShiftSql = string.Empty; for (DateTime date = StartDt; date.Date <= EndDt.Date; date = date.AddDays(1)) { string fldnm = "D" + date.ToString("dd"); string fldval = dr[fldnm].ToString().Trim().ToUpper(); try { string sqlattd = "Update AttdData " + " Set ScheduleShift ='" + fldval + "' Where tYear = '" + date.Year.ToString() + "' And tDate ='" + date.ToString("yyyy-MM-dd") + "' " + " And CompCode = '" + Emp.CompCode + "' And WrkGrp ='" + Emp.WrkGrp + "' And EmpUnqID='" + Emp.EmpUnqID + "'"; cmd = new SqlCommand(sqlattd, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { brkflg = true; dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); break; } ShiftSql += fldnm + " = '" + fldval + "',"; } //end foreach date if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } try { //update shiftschedule sql = "Update MastShiftSchedule Set " + ShiftSql.Substring(0, ShiftSql.Length - 1) + " Where Yearmt = '" + tYearMt + "' and EmpUnqId ='" + Emp.EmpUnqID + "' "; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { brkflg = true; dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); } if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } #endregion #region chk_LeavePosted if (leave.Count == 0) { #region ifnoleavefound //delete schedule wo string delsql = "Delete From MastLeaveSchedule Where tYear ='" + StartDt.Year.ToString() + "' " + " And tYearMT='" + tYearMt + "' " + " And EmpUnqID ='" + Emp.EmpUnqID + "' And SchLeave='WO' "; try { cmd = new SqlCommand(delsql, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; } if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } //'Insert "WO" MastLeaveSchedule Table for (DateTime date = StartDt; date.Date <= EndDt.Date; date = date.AddDays(1)) { string fldnm = "D" + date.ToString("dd"); string fldval = dr[fldnm].ToString().Trim().ToUpper(); if (fldval == "WO") { string inssql = " Insert into MastLeaveSchedule " + " ( EmpUnqID,WrkGrp,tDate,SchLeave,Adddt,AddId )" + " Values ('" + Emp.EmpUnqID + "','" + Emp.WrkGrp + "','" + date.ToString("yyyy-MM-dd") + "','WO',GetDate(),'ShiftSch')"; try { cmd = new SqlCommand(inssql, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } } } if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } #endregion } else { #region ifleavefound DateTime LastWO = new DateTime(); for (DateTime date = StartDt; date.Date <= EndDt.Date; date = date.AddDays(1)) { string fldnm = "D" + date.ToString("dd"); string fldval = dr[fldnm].ToString().Trim().ToUpper(); bool LeavPos = false; if (fldval == "WO") { foreach (LeaveData t in leave) { //check if date is fall between leave posted if (date >= t.FromDt && date <= t.ToDt) { LeavPos = true; date = t.ToDt; LastWO = t.ToDt; break; } } if (LeavPos) { continue; } //'if there is no leave posted on tdate if (!LeavPos) { if (LastWO != DateTime.MinValue) { try { string delwo = "Delete from MastLeaveSchedule Where EmpUnqID = '" + Emp.EmpUnqID + "' " + " and tDate > '" + LastWO.ToString("yyyy-MM-dd") + "' and tDate <= '" + date.ToString("yyyy-MM-dd") + "' and SchLeave ='WO'"; LastWO = date; cmd = new SqlCommand(delwo, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } } else { try { string delwo = "Delete from MastLeaveSchedule Where EmpUnqID = '" + Emp.EmpUnqID + "' and tDate = '" + date.ToString("yyyy-MM-dd") + "' and SchLeave ='WO'"; cmd = new SqlCommand(delwo, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } } try { string inssql = " Insert into MastLeaveSchedule ( EmpUnqID,WrkGrp,tDate,SchLeave,Adddt,AddId )" + " Values ('" + Emp.EmpUnqID + "','" + Emp.WrkGrp + "','" + date.ToString("yyyy-MM-dd") + "','WO',GetDate(),'ShiftSch')"; cmd = new SqlCommand(inssql, cn, trn); cmd.ExecuteNonQuery(); }catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } } }//end if WO else { LeavPos = false; foreach (LeaveData t in leave) { //check if date is fall between leave posted if (date >= t.FromDt && date <= t.ToDt) { LeavPos = true; break; } } if (!LeavPos) { try { sql = "Delete from MastLeaveSchedule Where EmpUnqID = '" + Emp.EmpUnqID + "' " + " and tDate = '" + date.ToString("yyyy-MM-dd") + "' and SchLeave ='WO'"; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } } } } //end of eachday if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } //remove any extra "WO" if try { if (LastWO != DateTime.MinValue) { sql = "Delete from MastLeaveSchedule Where EmpUnqID = '" + Emp.EmpUnqID + "' and tDate > '" + LastWO.ToString("yyyy-MM-dd") + "' " + " and tDate <= '" + EndDt.ToString("yyyy-MM-dd") + "' and SchLeave ='WO'"; cmd = new SqlCommand(sql, cn, trn); cmd.ExecuteNonQuery(); } } catch (Exception ex) { dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; break; } #endregion } //end if leavefound if (brkflg) { trn.Rollback(); cn.Close(); trn.Dispose(); continue; } #endregion try { trn.Commit(); dr["Remarks"] = "Uploded"; //process data if (ProcessFlg) { clsProcess pro = new clsProcess(); int result = 0; string proerr = string.Empty; pro.AttdProcess(Emp.EmpUnqID, StartDt, EndDt, out result, out proerr); if (result > 0) { pro.LunchInOutProcess(Emp.EmpUnqID, StartDt, EndDt, out result); //dr["remarks"] = dr["remarks"].ToString() + "Record updated..."; } } } catch (Exception ex) { trn.Rollback(); dr["Remarks"] = dr["Remarks"].ToString() + Environment.NewLine + ex.ToString(); brkflg = true; } trn.Dispose(); cn.Close(); } //using foreach of all employee } //using connection Cursor.Current = Cursors.Default; MessageBox.Show("file uploaded Successfully, please check the remarks for indivisual record status...", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } DataSet ds = new DataSet(); ds.Tables.Add(sortedDT); grd_view.DataSource = ds; grd_view.DataMember = ds.Tables[0].TableName; grd_view.Refresh(); Cursor.Current = Cursors.Default; txtYearMT.Enabled = true; btnBrowse.Enabled = true; btnPreview.Enabled = true; if (GRights.Contains("A") || GRights.Contains("U") || GRights.Contains("D")) { btnImport.Enabled = true; } else { btnImport.Enabled = false; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int leaveID = int.Parse(Request.QueryString["LeaveID"]); LeaveData leaveData = new LeaveData(); leaveData.Load(leaveID); if (!leaveData.HasData) { return; } trPSBirthDate.Visible = false; trPSWorkInDate.Visible = false; trWifeName.Visible = false; trGBDate.Visible = false; trOrdained.Visible = false; trTempleName.Visible = false; trTempleLocation.Visible = false; trOrdainDate.Visible = false; trHujed.Visible = false; trReason.Visible = false; trContact.Visible = false; trPhone.Visible = false; trRestSave.Visible = false; trRestLeft.Visible = false; trRestTotal.Visible = false; trStatistic.Visible = false; trCancelReason.Visible = false; /* trCLCancelComment.Visible = false; * trCLCancelDate.Visible = false; * trCHCancelComment.Visible = false; * trCHCancelDate.Visible = false; * trCHCancelAllow.Visible = false;*/ if (leaveData.LeaveTypeID == 1) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 2) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 3) { trStatistic.Visible = true; trReason.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 4) { trRestSave.Visible = true; trRestLeft.Visible = true; trRestTotal.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 5) { trWifeName.Visible = true; trGBDate.Visible = true; trContact.Visible = true; trPhone.Visible = true; } else if (leaveData.LeaveTypeID == 6) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trOrdained.Visible = true; trTempleName.Visible = true; trTempleLocation.Visible = true; trOrdainDate.Visible = true; } else if (leaveData.LeaveTypeID == 7) { trPSBirthDate.Visible = true; trPSWorkInDate.Visible = true; trHujed.Visible = true; } if (leaveData.LeaveStatusID >= 1 && leaveData.LeaveStatusID <= 3) { } else if (leaveData.LeaveStatusID >= 4 && leaveData.LeaveStatusID <= 6) { trCancelReason.Visible = true; /* trCLCancelComment.Visible = true; * trCLCancelDate.Visible = true; * trCHCancelComment.Visible = true; * trCHCancelDate.Visible = true; * trCHCancelAllow.Visible = true;*/ } lbLeaveID.Text = leaveData.LeaveID.ToString(); lbLeaveStatusID.Text = leaveData.LeaveStatusName; lbLeaveType.Text = leaveData.LeaveTypeName; lbReqDate.Text = leaveData.RequestDate.Value.ToLongDateString(); lbPSName.Text = leaveData.Person.PS_FIRSTNAME + " " + leaveData.Person.PS_LASTNAME; lbPSPos.Text = leaveData.Person.PS_WORK_POS_NAME; lbPSAPos.Text = leaveData.Person.PS_ADMIN_POS_NAME; if (Util.IsBlank(leaveData.Person.PS_WORK_DIVISION_NAME)) { lbPSDept.Text = leaveData.Person.PS_DIVISION_NAME; } else { lbPSDept.Text = leaveData.Person.PS_WORK_DIVISION_NAME; } //if (leaveData.PS_BirthDate.HasValue) { lbPSBirthDate.Text = leaveData.Person.PS_BIRTHDAY_DATE.Value.ToLongDateString(); //} else { // lbPSBirthDate.Text = "-"; //} //if (leaveData.PS_WorkInDate.HasValue) { lbPSWorkInDate.Text = leaveData.Person.PS_INWORK_DATE.Value.ToLongDateString(); //} else { // lbPSWorkInDate.Text = "-"; // } lbRestSave.Text = leaveData.RestSave + " วัน"; lbRestLeft.Text = leaveData.RestLeft + " วัน"; lbRestTotal.Text = leaveData.RestTotal + " วัน"; lbWifeName.Text = leaveData.WifeFirstName + " " + leaveData.WifeLastName; if (leaveData.GiveBirthDate.HasValue) { lbGBDate.Text = leaveData.GiveBirthDate.Value.ToLongDateString(); } else { lbGBDate.Text = "-"; } lbOrdained.Text = leaveData.Ordained == 1 ? "เคย" : "ไม่เคย"; lbTempleName.Text = leaveData.TempleName; lbTempleLocation.Text = leaveData.TempleLocation; if (leaveData.OrdainDate.HasValue) { lbOrdainDate.Text = leaveData.OrdainDate.Value.ToLongDateString(); } else { lbOrdainDate.Text = "-"; } lbHujed.Text = leaveData.Hujed == 1 ? "เคย" : "ไม่เคย"; if (leaveData.FromDate.HasValue) { lbFTTDate.Text = leaveData.FromDate.Value.ToLongDateString() + " ถึง " + leaveData.ToDate.Value.ToLongDateString() + " รวม " + leaveData.TotalDay + " วัน"; } else { lbFTTDate.Text = "ไม่เคยลา"; } lbStatistic.Text = "ลามาแล้ว " + leaveData.CountPast + " วัน / ลาครั้งนี้ " + leaveData.CountNow + " วัน / รวม " + leaveData.CountTotal + " วัน"; lbReason.Text = leaveData.Reason; lbContact.Text = leaveData.Contact; lbPhone.Text = leaveData.Telephone; if (leaveData.LastFromDate.HasValue) { lbLastFTTDate.Text = leaveData.LastFromDate.Value.ToLongDateString() + " ถึง " + leaveData.LastToDate.Value.ToLongDateString() + " รวม " + leaveData.LastTotalDay + " วัน"; } else { lbLastFTTDate.Text = "ไม่เคยลา"; } { TableRow row = new TableRow(); TableCell cell2; Image image; tbBoss.Rows.Add(row); for (int j = 0; j < leaveData.BossStateMax; j++) { LeaveBossData leaveBossData = leaveData.LeaveBossDataList[j]; cell2 = new TableCell(); cell2.Style.Add("vertical-align", "top"); Table tb = new Table(); tb.CssClass = "ps-table-1"; tb.Style.Add("text-align", "left"); { TableRow tr; TableCell cell3; tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.ColumnSpan = 2; cell3.Style.Add("text-align", "center"); image = new Image(); image.CssClass = "ps-ms-main-drop-profile-pic"; string imagePath = DatabaseManager.GetPersonImageFileName(leaveBossData.CitizenID); if (imagePath != "") { image.Attributes["src"] = "Upload/PersonImage/" + imagePath; cell3.Controls.Add(image); } tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ชื่อ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.FirstNameAndLastName; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ตำแหน่ง"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PS_WORK_POS_NAME; tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "ระดับ"; tr.Cells.Add(cell3); cell3 = new TableCell(); cell3.Text = leaveBossData.Person.PS_ADMIN_POS_NAME;// + "<br />" + leaveBossData.Person.AdminPositionNameExtra(); tr.Cells.Add(cell3); tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "การอนุมัติ"; tr.Cells.Add(cell3); cell3 = new TableCell(); if (leaveBossData.Allow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.AllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.Allow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.Comment + "</div>"; } tr.Cells.Add(cell3); if (leaveData.CancelAllow.HasValue) { tr = new TableRow(); tb.Rows.Add(tr); cell3 = new TableCell(); cell3.Text = "การอนุมัติยกเลิก"; tr.Cells.Add(cell3); cell3 = new TableCell(); if (leaveBossData.CancelAllow.HasValue) { cell3.Text = "<div style='color: #808080;'>" + leaveBossData.CancelAllowDate.Value.ToLongDateString() + "</div>"; if (leaveBossData.CancelAllow.Value == 1) { cell3.Text += "<div style='color: green'>อนุญาต</div>"; } else { cell3.Text += "<div style='color: red'>ไม่อนุญาต</div>"; } cell3.Text += "<div style='color: #000000;'>" + leaveBossData.CancelComment + "</div>"; } tr.Cells.Add(cell3); } } cell2.Controls.Add(tb); row.Cells.Add(cell2); } } /*if(leaveData.CL_ID == null) { * lbCLName.Text = "-"; * lbCLPos.Text = "-"; * lbCLCom.Text = "-"; * lbCLDate.Text = "-"; * } else { * lbCLName.Text = leaveData.CL_Title + leaveData.CL_FirstName + " " + leaveData.CL_LastName; * lbCLPos.Text = leaveData.CL_Position; * if (leaveData.CL_Comment != "") { * lbCLCom.Text = leaveData.CL_Comment; * } else { * lbCLCom.Text = "-"; * } * if (leaveData.CL_Date.HasValue) { * lbCLDate.Text = leaveData.CL_Date.Value.ToLongDateString(); * } else { * lbCLDate.Text = "-"; * } * } * * * lbCHName.Text = leaveData.CH_Title + leaveData.CH_FirstName + " " + leaveData.CH_LastName; * lbCHPos.Text = leaveData.CH_Position; * if (leaveData.CH_Comment != "") { * lbCHCom.Text = leaveData.CH_Comment; * } else { * lbCHCom.Text = "-"; * } * if (leaveData.CH_Date.HasValue) { * lbCHDate.Text = leaveData.CH_Date.Value.ToLongDateString(); * lbCHAllow.Text = leaveData.CH_Allow == 1 ? "อนุมัติ" : "ไม่อนุมัติ"; * } else { * lbCHDate.Text = "-"; * lbCHAllow.Text = "-"; * } * * if (leaveData.DocterCertificationFileName != "") { * string loc = "Upload/DrCer/" + leaveData.DocterCertificationFileName; * div_dr_cer.InnerHtml += "<a href='" + loc + "'><img src='" + loc + "' /></a>"; * } * * if (leaveData.LeaveStatusID >= 1 && leaveData.LeaveStatusID <= 4) { * * } else if (leaveData.LeaveStatusID >= 5 && leaveData.LeaveStatusID <= 8) { * lbCancelReason.Text = leaveData.CancelReason; * if (leaveData.CL_CancelDate.HasValue) { * lbCL_C_Com.Text = leaveData.CL_CancelComment; * lbCL_C_Date.Text = leaveData.CL_CancelDate.Value.ToLongDateString(); * } else { * lbCL_C_Com.Text = "-"; * lbCL_C_Date.Text = "-"; * } * if (leaveData.CH_CancelDate.HasValue) { * lbCH_C_Com.Text = leaveData.CH_CancelComment; * lbCH_C_Date.Text = leaveData.CH_CancelDate.Value.ToLongDateString(); * lbCH_C_Allow.Text = leaveData.CH_CancelAllow == 1 ? "อนุมัติ" : "ไม่อนุมัติ"; * } else { * lbCH_C_Com.Text = "-"; * lbCH_C_Date.Text = "-"; * lbCH_C_Allow.Text = "-"; * } * * } * * string _psCLImage = DatabaseManager.GetPersonImageFileName(leaveData.CL_ID); * string _psCHImage = DatabaseManager.GetPersonImageFileName(leaveData.CH_ID); * if (_psCLImage != "") { * psCLImage.Src = "Upload/PersonImage/" + _psCLImage; * } * if (_psCHImage != "") { * psCHImage.Src = "Upload/PersonImage/" + _psCHImage; * }*/ } }
private void FuncGVFinish() { OracleConnection.ClearAllPools(); SqlDataSource sds = DatabaseManager.CreateSQLDataSource("SELECT LEAVE_ID รหัสการลา, (SELECT LEAVE_TYPE_NAME FROM LEV_TYPE WHERE LEV_TYPE.LEAVE_TYPE_ID = LEV_DATA.LEAVE_TYPE_ID) ประเภทการลา, REQ_DATE วันที่ข้อมูล, FROM_DATE จากวันที่, TO_DATE ถึงวันที่, TOTAL_DAY รวมวัน, (SELECT LEAVE_STATUS_NAME FROM LEV_STATUS WHERE LEV_STATUS.LEAVE_STATUS_ID = LEV_DATA.LEAVE_STATUS_ID) สถานะ, NVL(V_ALLOW,0) ผลการอนุมัติ FROM LEV_DATA WHERE LEAVE_STATUS_ID in(2,5) AND PS_ID = '" + loginPerson.PS_CITIZEN_ID + "' ORDER BY LEAVE_ID DESC"); gvFinish.DataSource = sds; gvFinish.DataBind(); if (gvFinish.Rows.Count > 0) { lbFinish.Visible = false; TableHeaderCell headerCell = new TableHeaderCell(); headerCell.Text = "ตกลง"; gvFinish.HeaderRow.Cells.Add(headerCell); gvFinish.HeaderRow.Cells[0].Text = "<img src='Image/Small/ID.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[0].Text; gvFinish.HeaderRow.Cells[1].Text = "<img src='Image/Small/list.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[1].Text; gvFinish.HeaderRow.Cells[2].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[2].Text; gvFinish.HeaderRow.Cells[3].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[3].Text; gvFinish.HeaderRow.Cells[4].Text = "<img src='Image/Small/calendar.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[4].Text; gvFinish.HeaderRow.Cells[6].Text = "<img src='Image/Small/question.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[6].Text; gvFinish.HeaderRow.Cells[7].Text = "<img src='Image/Small/correct.png' class='icon_left'/>" + gvFinish.HeaderRow.Cells[7].Text; for (int i = 0; i < gvFinish.Rows.Count; ++i) { string ID = gvFinish.Rows[i].Cells[0].Text; TableCell cell = new TableCell(); LinkButton btn = new LinkButton(); btn.CssClass = "ps-button-img"; btn.Text = "ตกลง"; btn.Click += (e2, e3) => { LeaveData leaveData = new LeaveData(); leaveData.Load(int.Parse(ID)); if (leaveData.LeaveStatusID == 2) { DatabaseManager.ExecuteNonQuery("UPDATE LEV_DATA SET LEAVE_STATUS_ID = 3 WHERE LEAVE_ID = " + ID); } else if (leaveData.LeaveStatusID == 5) { DatabaseManager.ExecuteNonQuery("UPDATE LEV_DATA SET LEAVE_STATUS_ID = 6 WHERE LEAVE_ID = " + ID); } Response.Redirect("LeaveHistory.aspx"); }; cell.Controls.Add(btn); gvFinish.Rows[i].Cells.Add(cell); if (Util.StringEqual(gvFinish.Rows[i].Cells[7].Text, new string[] { "2" })) { gvFinish.Rows[i].Cells[7].Text = "ไม่อนุญาต"; gvFinish.Rows[i].Cells[7].ForeColor = System.Drawing.Color.Red; } if (Util.StringEqual(gvFinish.Rows[i].Cells[7].Text, new string[] { "1" })) { gvFinish.Rows[i].Cells[7].Text = "อนุญาต"; gvFinish.Rows[i].Cells[7].ForeColor = System.Drawing.Color.Green; } } Util.NormalizeGridViewDate(gvFinish, 2); Util.NormalizeGridViewDate(gvFinish, 3); Util.NormalizeGridViewDate(gvFinish, 4); } else { lbFinish.Visible = true; } }
/// <summary> /// Gets the leave detail. /// </summary> /// <param name="leaveId">The leave identifier.</param> /// <param name="userId">The user identifier.</param> /// <returns> Leave Detail with comments </returns> public LeaveData GetLeaveDetail(int leaveId, int userId) { var leaveData = new LeaveData(); var leaveDetail = this.unitOfWork.Context.RetrieveLeaveDetail(leaveId, userId).FirstOrDefault(); if (leaveDetail != null) { leaveData.DayCount = leaveDetail.DayCount.HasValue ? leaveDetail.DayCount.Value : default(decimal); leaveData.DeveloperName = leaveDetail.DeveloperName; leaveData.FromDate = leaveDetail.FromDate.HasValue ? leaveDetail.FromDate.Value : default(DateTime); leaveData.ToDate = leaveDetail.ToDate.HasValue ? leaveDetail.ToDate.Value : default(DateTime); leaveData.LeaveId = leaveId; leaveData.Status = leaveDetail.Status.HasValue ? leaveDetail.Status.Value : default(byte); leaveData.SupervisorName = leaveDetail.SupervisorName; leaveData.Designation = leaveDetail.Designation; leaveData.Reason = leaveDetail.Reason; leaveData.LeaveType = leaveDetail.LeaveType; leaveData.DeveloperId = leaveDetail.DeveloperID.HasValue ? leaveDetail.DeveloperID.Value : default(int); leaveData.Type = leaveDetail.Type.HasValue ? leaveDetail.Type.Value : default(byte); leaveData.FromDateDayType = leaveDetail.FromDateDayType.HasValue ? leaveDetail.FromDateDayType.Value : default(byte); leaveData.ToDateDayType = leaveDetail.ToDateDayType.HasValue ? leaveDetail.ToDateDayType.Value : default(byte); leaveData.IsMyTeam = leaveDetail.MyTeamFlag.HasValue ? leaveDetail.MyTeamFlag.Value : default(bool); leaveData.EscalatedFlag = leaveDetail.EscalatedFlag.HasValue ? leaveDetail.EscalatedFlag.Value : default(bool); } var leaveComments = this.unitOfWork.Context.RetrieveLeaveComments(leaveId).ToList(); foreach (var leaveComment in leaveComments) { leaveData.Comments.Add(leaveComment); } return leaveData; }