//public int CreateNew(FP_AttendanceVO vo) //{ // int id = 0; // try // { // id = dao.Insert(vo); // } // catch (SqlException sqlEx) // { // MessageBox.Show("Update Error:" + sqlEx); // } // return id; //} //public int CreateFromOtherActivity(FP_AttendanceVO vo) //{ // int id=0; // try{ // // if (!dao.isExist(" InDate='" + vo.InDate + "' AND OutDate='" + vo.OutDate + "' AND EMPID='" + vo.EmpID + "' and ShiftID=" + vo.ShiftID)) // if (!dao.isExist(" InDate='" + vo.InDate + "' AND EMPID='" + vo.EmpID + "' and ShiftID=" + vo.ShiftID)) // { // id = dao.Insert(vo); // } // else // { // id = dao.Update(vo); // } // }catch(Exception ex) // { // throw ex; // } // return id; //} public int CreateAttendance(FP_AttendanceVO vo) { int id = 0; string condition = "ShiftDateIn='" + vo.ShiftDateIn + "' AND ShiftDateOut='" + vo.ShiftDateOut + "' AND InDate='" + vo.InDate + "' AND OutDate='" + vo.OutDate + "' AND EMPID='" + vo.EmpID + "' and ShiftID=" + vo.ShiftID; //string condition = " InDate='" + vo.InDate + "' AND EMPID='" + vo.EmpID + "' and ShiftID=" + vo.ShiftID; DataTable dt = b.Select("FP_Attendance", condition); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { bool flg = (bool)dr["isOtherActivity"]; if (!flg) { id = dao.Update(vo); } } } else { id = dao.Insert(vo); } return(id); }
public FP_AttendanceVO GetByID(int id) { FP_AttendanceVO vo = new FP_AttendanceVO(); DataTable dt = Select(String.Format("ID={0}", id)); if (dt.Rows.Count > 0) { vo = b.ConvertObjWithImage(dt.Rows[0], new FP_AttendanceVO()) as FP_AttendanceVO; } return(vo); }
public int Update(FP_AttendanceVO vo) { int ID = 0; try { b.UpdateByConditon("FP_Attendance", "ShiftDateIn='" + vo.ShiftDateIn + "' AND ShiftDateOut='" + vo.ShiftDateOut + "' AND InDate='" + vo.InDate + "' AND OutDate='" + vo.OutDate + "' AND EMPID='" + vo.EmpID + "' AND ShiftID='" + vo.ShiftID + "'", b.ConvertColName(vo), b.ConvertValueList(vo)); ID = vo.Id; } catch (Exception ex) { throw ex; } return(ID); }
public int UpdateByAttendanceID(FP_AttendanceVO vo) { int ID = 0; try { b.Update("FP_Attendance", vo.Id.ToString(), b.ConvertColName(vo), b.ConvertValueListNullable(vo)); ID = vo.Id; } catch (SqlException ex) { throw ex; } return(ID); }
//public int Create(FP_AttendanceVO vo) //{ // int id; // if (!dao.isExist(" InDate='" + vo.InDate+ "' AND OutDate='"+ vo.OutDate+ "' AND EMPID='" + vo.EmpID + "' and ScheduleID="+ vo.ScheduleId)) // { // id = dao.Insert(vo); // } // else // { // id = dao.Update(vo); // } // return id; //} //public int Update(FP_AttendanceVO vo) //{ // int id = 0; // try // { // id = dao.Update(vo); // } // catch (SqlException sqlEx) // { // MessageBox.Show("Update Error:" + sqlEx); // } // return id; //} public int UpdateByAttendanceID(FP_AttendanceVO vo) { int id = 0; try { id = dao.UpdateByAttendanceID(vo); } catch (SqlException sqlEx) { MessageBox.Show("Update Error:" + sqlEx); } return(id); }
public int Insert(FP_AttendanceVO vo) { //if (vo.InTime == TimeSpan.Parse("00:00:00")) //{ // if (vo.Late > TimeSpan.Parse("23:59:59")) // vo.Late = TimeSpan.Parse("00:00:00"); //} //if (vo.OutTime == TimeSpan.Parse("00:00:00")) //{ // if (vo.EarlyOut > TimeSpan.Parse("23:59:59")) // vo.EarlyOut = TimeSpan.Parse("00:00:00"); //} int lastInsertId = 0; try { string condition = "ShiftDateIn='" + vo.ShiftDateIn + "' AND ShiftDateOut='" + vo.ShiftDateOut + "' AND InDate='" + vo.InDate + "' AND OutDate='" + vo.OutDate + "' AND EMPID='" + vo.EmpID + "' and ShiftID=" + vo.ShiftID; DataTable dt = b.Select("FP_Attendance", condition); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { bool flg = (bool)dr["isOtherActivity"]; if (!flg) { FP_AttendanceDAO dao = new FP_AttendanceDAO(); lastInsertId = dao.Update(vo); } } } else { // id = dao.Insert(vo); lastInsertId = b.Insert("FP_Attendance", b.ConvertColName(vo), b.ConvertValueListNullable(vo)); } //lastInsertId = b.Insert("FP_Attendance", b.ConvertColName(vo), b.ConvertValueList(vo)); } catch (Exception ex) { throw ex; } return(lastInsertId); }