本文整理汇总了C#中WMS.Models.TAS2013Entities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# TAS2013Entities.SaveChanges方法的具体用法?C# TAS2013Entities.SaveChanges怎么用?C# TAS2013Entities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WMS.Models.TAS2013Entities
的用法示例。
在下文中一共展示了TAS2013Entities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadImageInDataBase
public int UploadImageInDataBase(HttpPostedFileBase file, string _empNo)
{
using (var context = new TAS2013Entities())
{
List<EmpPhoto> _empPhotoList = new List<EmpPhoto>();
EmpPhoto _EmpPhoto = new EmpPhoto();
Emp _Emp = new Emp();
int empPhotoID = 0;
_Emp = context.Emps.First(aa => aa.EmpNo == _empNo);
_empPhotoList = context.EmpPhotoes.Where(aa => aa.EmpID == _Emp.EmpID).ToList();
_EmpPhoto.EmpPic = ConvertToBytes(file);
if (_empPhotoList.Count > 0)
{
//Update Existing Image
_EmpPhoto.EmpID = _empPhotoList.FirstOrDefault().EmpID;
_EmpPhoto.PhotoID = _empPhotoList.FirstOrDefault().PhotoID;
}
else
{
//Add New Image
_EmpPhoto.EmpID = _Emp.EmpID;
context.EmpPhotoes.Add(_EmpPhoto);
}
try
{
empPhotoID = _EmpPhoto.PhotoID;
context.SaveChanges();
return empPhotoID;
}
catch (Exception ex)
{
return empPhotoID;
}
}
}
示例2: AddHalfLeaveToLeaveData
public void AddHalfLeaveToLeaveData(LvApplication lvappl)
{
DateTime datetime = new DateTime();
datetime = lvappl.FromDate;
string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
LvData _LVData = new LvData();
_LVData.EmpID = lvappl.EmpID;
_LVData.EmpDate = _EmpDate;
_LVData.Remarks = lvappl.LvReason;
_LVData.HalfLeave = true;
_LVData.LvID = lvappl.LvID;
_LVData.AttDate = datetime.Date;
_LVData.LvCode = lvappl.LvType;
_LVData.FirstHalf = lvappl.FirstHalf;
try
{
using (var db = new TAS2013Entities())
{
db.LvDatas.Add(_LVData);
db.SaveChanges();
}
}
catch (Exception ex)
{
}
// Balance Leaves from Emp Table
BalanceLeaves(lvappl);
}
示例3: UploadImageInDataBase
public int UploadImageInDataBase(HttpPostedFileBase file, Emp _Emp)
{
using (var context = new TAS2013Entities())
{
List<EmpPhoto> _empPhotoList = new List<EmpPhoto>();
EmpPhoto _EmpPhoto = new EmpPhoto();
int empPhotoID = 0;
_empPhotoList = context.EmpPhotoes.Where(aa => aa.EmpID == _Emp.EmpID).ToList();
_EmpPhoto.EmpPic = ConvertToBytes(file);
if (_empPhotoList.Count > 0)
{
_EmpPhoto.PhotoID = _empPhotoList.FirstOrDefault().PhotoID;
_empPhotoList.FirstOrDefault().EmpPic = _EmpPhoto.EmpPic;
context.EmpPhotoes.Attach(_empPhotoList.FirstOrDefault());
context.Entry(_empPhotoList.FirstOrDefault()).State = EntityState.Modified;
context.SaveChanges();
}
else
{
//Add New Image
_EmpPhoto.EmpID = _Emp.EmpID;
context.EmpPhotoes.Add(_EmpPhoto);
}
try
{
empPhotoID = _EmpPhoto.PhotoID;
context.SaveChanges();
return empPhotoID;
}
catch (Exception ex)
{
return empPhotoID;
}
}
}
示例4: AddHalfLeaveToAttData
public void AddHalfLeaveToAttData(LvApplication lvappl)
{
DateTime datetime = new DateTime();
datetime = lvappl.FromDate;
string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
using (var db = new TAS2013Entities())
{
if (db.AttProcesses.Where(aa => aa.ProcessDate == datetime).Count() > 0)
{
AttData _EmpAttData = new AttData();
_EmpAttData = db.AttDatas.First(aa => aa.EmpDate == _EmpDate);
if (lvappl.LvType == "A")//Casual Leave
_EmpAttData.Remarks = _EmpAttData.Remarks+"[H-CL]";
if (lvappl.LvType == "B")//Anual Leave
_EmpAttData.Remarks = _EmpAttData.Remarks+"[H-AL]";
if (lvappl.LvType == "C")//Sick Leave
_EmpAttData.Remarks = _EmpAttData.Remarks+"[H-SL]";
if (_EmpAttData.Remarks.Contains("[Absent]"))
_EmpAttData.Remarks.Replace("[Abesnt]", "");
if (_EmpAttData.Remarks.Contains("[EO]"))
_EmpAttData.Remarks.Replace("[EO]", "-");
if (_EmpAttData.Remarks.Contains("[LI]"))
_EmpAttData.Remarks.Replace("[LI]", "");
_EmpAttData.StatusLeave = true;
if (lvappl.FirstHalf == true)
{
_EmpAttData.LateIn = 0;
_EmpAttData.StatusLI = false;
}
else
{
_EmpAttData.StatusEO = false;
_EmpAttData.EarlyOut = 0;
}
//_EmpAttData.statushl
db.SaveChanges();
}
}
}
示例5: BalanceLeaves
public void BalanceLeaves(LvApplication lvappl)
{
using (var ctx = new TAS2013Entities())
{
List<LvConsumed> _lvConsumed = new List<LvConsumed>();
string empLvType = lvappl.EmpID.ToString() + lvappl.LvType;
_lvConsumed = ctx.LvConsumeds.Where(aa => aa.EmpLvType == empLvType).ToList();
float _NoOfDays = lvappl.NoOfDays;
if (_lvConsumed.Count > 0)
{
_lvConsumed.FirstOrDefault().YearRemaining = (float)(_lvConsumed.FirstOrDefault().YearRemaining - _NoOfDays);
_lvConsumed.FirstOrDefault().GrandTotalRemaining = (float)(_lvConsumed.FirstOrDefault().GrandTotalRemaining - _NoOfDays);
if (lvappl.IsHalf == true)
{
AddHalfLeaveBalancceMonthQuota(_lvConsumed, lvappl);
}
else
{
AddBalancceMonthQuota(_lvConsumed, lvappl);
}
ctx.SaveChanges();
}
ctx.Dispose();
}
}
示例6: AddShortLeaveToAttData
public void AddShortLeaveToAttData(LvShort lvshort)
{
DateTime datetime = new DateTime();
using (var db = new TAS2013Entities())
{
if (db.AttProcesses.Where(aa => aa.ProcessDate == datetime).Count() > 0)
{
AttData _EmpAttData = new AttData();
_EmpAttData = db.AttDatas.First(aa => aa.EmpDate == lvshort.EmpDate);
_EmpAttData.StatusAB = false;
_EmpAttData.StatusSL = true;
_EmpAttData.Remarks = _EmpAttData.Remarks + "[Short Leave]";
db.SaveChanges();
}
}
}
示例7: AddLeaveToLeaveData
public bool AddLeaveToLeaveData(LvApplication lvappl)
{
DateTime datetime = new DateTime();
datetime = lvappl.FromDate;
for (int i = 0; i < lvappl.NoOfDays; i++)
{
string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
LvData _LVData = new LvData();
_LVData.EmpID = lvappl.EmpID;
_LVData.EmpDate = _EmpDate;
_LVData.Remarks = lvappl.LvReason;
_LVData.LvID = lvappl.LvID;
_LVData.AttDate = datetime.Date;
_LVData.LvCode = lvappl.LvType;
_LVData.CompanyID = lvappl.CompanyID;
try
{
using (var context = new TAS2013Entities())
{
context.LvDatas.Add(_LVData);
context.SaveChanges();
}
}
catch (Exception ex)
{
}
datetime = datetime.AddDays(1);
// Balance Leaves from Emp Table
}
BalanceLeaves(lvappl);
return true;
}
示例8: AddLateInMarginAttData
private bool AddLateInMarginAttData(string _empDate, int _empID, DateTime _Date, int _userID, short _WorkCardID)
{
bool check = false;
try
{
//Late In Job Card
short LateInMins = 0;
using (var context = new TAS2013Entities())
{
AttData _attdata = context.AttDatas.FirstOrDefault(aa => aa.EmpDate == _empDate);
if (_attdata != null)
{
_attdata.StatusAB = false;
_attdata.Remarks.Replace("[LI]", "");
_attdata.Remarks = _attdata.Remarks + "[LI Job Card]";
_attdata.LateIn = 0;
_attdata.WorkMin = (short)(_attdata.WorkMin + (short)LateInMins);
_attdata.StatusLI = false;
}
context.SaveChanges();
if (context.SaveChanges() > 0)
check = true;
context.Dispose();
}
}
catch (Exception ex)
{
}
return check;
}
示例9: SaveAuditLog
public static void SaveAuditLog(int _userID,short _form,short _operation,DateTime _date)
{
using (var ctx = new TAS2013Entities())
{
AuditLog auditEntry = new AuditLog();
auditEntry.AuditUserID = _userID;
auditEntry.FormID = _form;
auditEntry.OperationID = _operation;
auditEntry.AuditDateTime = _date;
ctx.AuditLogs.Add(auditEntry);
ctx.SaveChanges();
}
}
示例10: AddLeaveToLeaveAttData
public bool AddLeaveToLeaveAttData(LvApplication lvappl)
{
try
{
DateTime datetime = new DateTime();
datetime = lvappl.FromDate;
for (int i = 0; i < lvappl.NoOfDays; i++)
{
string _EmpDate = lvappl.EmpID + datetime.Date.ToString("yyMMdd");
using (var context = new TAS2013Entities())
{
if (context.AttProcesses.Where(aa => aa.ProcessDate == datetime).Count() > 0)
{
AttData _EmpAttData = new AttData();
_EmpAttData = context.AttDatas.First(aa => aa.EmpDate == _EmpDate);
_EmpAttData.TimeIn = null;
_EmpAttData.TimeOut = null;
_EmpAttData.WorkMin = null;
_EmpAttData.LateIn = null;
_EmpAttData.LateOut = null;
_EmpAttData.EarlyIn = null;
_EmpAttData.EarlyOut = null;
_EmpAttData.StatusAB= false;
_EmpAttData.StatusLeave = true;
_EmpAttData.StatusEI = null;
_EmpAttData.StatusEO = null;
_EmpAttData.StatusLI = null;
_EmpAttData.StatusLI= null;
_EmpAttData.StatusLO = null;
_EmpAttData.StatusDO = null;
_EmpAttData.StatusGZ = null;
_EmpAttData.StatusGZOT = null;
_EmpAttData.StatusMN = null;
_EmpAttData.StatusOD = null;
if (lvappl.LvType == "A")//Casual Leave
_EmpAttData.Remarks = "[CL]";
if (lvappl.LvType == "B")//Anual Leave
_EmpAttData.Remarks = "[AL]";
if (lvappl.LvType == "C")//Sick Leave
_EmpAttData.Remarks = "[SL]";
_EmpAttData.StatusAB = false;
_EmpAttData.StatusLeave = true;
context.SaveChanges();
}
}
datetime = datetime.AddDays(1);
}
}
catch (Exception ex)
{
return false;
}
return true;
}
示例11: UpdateLeaveBalance
public void UpdateLeaveBalance(LvApplication lvappl)
{
float LvDays = (float)lvappl.NoOfDays;
List<LvConsumed> _lvConsumed = new List<LvConsumed>();
using (var ctx = new TAS2013Entities())
{
string empLvType = lvappl.EmpID.ToString() + lvappl.LvType;
_lvConsumed = ctx.LvConsumeds.Where(aa => aa.EmpLvType == empLvType).ToList();
if (_lvConsumed.Count > 0)
{
_lvConsumed.FirstOrDefault().YearRemaining = (float)(_lvConsumed.FirstOrDefault().YearRemaining + LvDays);
_lvConsumed.FirstOrDefault().GrandTotalRemaining = (float)(_lvConsumed.FirstOrDefault().GrandTotalRemaining + LvDays);
SubtractBalancceMonthQuota(_lvConsumed, lvappl);
ctx.SaveChanges();
}
ctx.Dispose();
}
}
示例12: DeleteHLFromLVData
public void DeleteHLFromLVData(LvApplication lvappl)
{
int _EmpID = lvappl.EmpID;
DateTime Date = lvappl.FromDate;
while (Date <= lvappl.ToDate)
{
using (var context = new TAS2013Entities())
{
var _id = context.LvDatas.Where(aa => aa.EmpID == _EmpID && aa.AttDate == Date.Date).FirstOrDefault().EmpDate;
if (_id != null)
{
LvData lvvdata = context.LvDatas.Find(_id);
//lvvdata.Active = false;
context.LvDatas.Remove(lvvdata);
context.SaveChanges();
}
}
Date = Date.AddDays(1);
}
}
示例13: ManualProcessAttendance
public void ManualProcessAttendance(DateTime date, List<Emp> emps)
{
BootstrapAttendance(date, emps);
DateTime dateEnd = date.AddDays(1);
List<AttData> attData = context.AttDatas.Where(aa => aa.AttDate >= date && aa.AttDate <= dateEnd).ToList();
List<PollData> unprocessedPolls = context.PollDatas.Where(p => (p.EntDate >= date && p.EntDate <= dateEnd)).OrderBy(e => e.EntTime).ToList();
foreach (var emp in emps)
{
List<PollData> polls = new List<PollData>();
polls = unprocessedPolls.Where(p => p.EmpID == emp.EmpID).OrderBy(e => e.EntTime).ToList();
foreach (PollData up in polls)
{
try
{
//Check AttData with EmpDate
if (attData.Where(attd => attd.EmpDate == up.EmpDate).Count() > 0)
{
AttData attendanceRecord = attData.First(attd => attd.EmpDate == up.EmpDate);
employee = attendanceRecord.Emp;
Shift shift = employee.Shift;
//Set Time In and Time Out in AttData
if (attendanceRecord.Emp.Shift.OpenShift == true)
{
//Set Time In and Time Out for open shift
PlaceTimeInOuts.CalculateTimeINOUTOpenShift(attendanceRecord, up);
context.SaveChanges();
}
else
{
TimeSpan checkTimeEnd = new TimeSpan();
DateTime TimeInCheck = new DateTime();
if (attendanceRecord.TimeIn == null)
{
TimeInCheck = attendanceRecord.AttDate.Value.Add(attendanceRecord.DutyTime.Value);
}
else
TimeInCheck = attendanceRecord.TimeIn.Value;
if (attendanceRecord.ShifMin == 0)
checkTimeEnd = TimeInCheck.TimeOfDay.Add(new TimeSpan(0, 480, 0));
else
checkTimeEnd = TimeInCheck.TimeOfDay.Add(new TimeSpan(0, (int)attendanceRecord.ShifMin, 0));
if (checkTimeEnd.Days > 0)
{
//if Time out occur at next day
if (up.RdrDuty == 5)
{
DateTime dt = new DateTime();
dt = up.EntDate.Date.AddDays(-1);
var _attData = context.AttDatas.FirstOrDefault(aa => aa.AttDate == dt && aa.EmpID == up.EmpID);
if (_attData != null)
{
if (_attData.TimeIn != null)
{
TimeSpan t1 = new TimeSpan(11, 00, 00);
if (up.EntTime.TimeOfDay < t1)
{
if ((up.EntTime - _attData.TimeIn.Value).Hours < 18)
{
attendanceRecord = _attData;
up.EmpDate = up.EmpID.ToString() + dt.Date.ToString("yyMMdd");
}
}
}
else
{
attendanceRecord = _attData;
up.EmpDate = up.EmpID.ToString() + dt.Date.ToString("yyMMdd");
}
}
}
}
//Set Time In and Time Out
//Set Time In and Time Out
if (up.RdrDuty == 5)
{
if (attendanceRecord.TimeIn != null)
{
TimeSpan dt = (TimeSpan)(up.EntTime.TimeOfDay - attendanceRecord.TimeIn.Value.TimeOfDay);
if (dt.Minutes < 0)
{
DateTime dt1 = new DateTime();
dt1 = up.EntDate.Date.AddDays(-1);
var _attData = context.AttDatas.FirstOrDefault(aa => aa.AttDate == dt1 && aa.EmpID == up.EmpID);
attendanceRecord = _attData;
up.EmpDate = up.EmpID.ToString() + dt1.Date.ToString("yyMMdd");
PlaceTimeInOuts.CalculateTimeINOUT(attendanceRecord, up);
}
else
PlaceTimeInOuts.CalculateTimeINOUT(attendanceRecord, up);
}
else
PlaceTimeInOuts.CalculateTimeINOUT(attendanceRecord, up);
}
else
PlaceTimeInOuts.CalculateTimeINOUT(attendanceRecord, up);
}
if (employee.Shift.OpenShift == true)
{
//.........这里部分代码省略.........
示例14: BootstrapAttendance
//.........这里部分代码省略.........
att.ShifMin = roster.WorkMin;
att.DutyCode = "D";
att.DutyTime = roster.DutyTime;
}
}
//////////////////////////
// Check for GZ Day //
////////////////////////
//Set DutyCode = R, StatusAB=false, StatusGZ = true, and Remarks=[GZ]
if (emp.Shift.GZDays == true)
{
if (context.Holidays.Where(hol => hol.HolDate == dateTime).Count() > 0)
{
att.DutyCode = "G";
att.StatusAB = false;
att.StatusGZ = true;
att.Remarks = "[GZ]";
att.ShifMin = 0;
}
}
////////////////////////////
//TODO Check for Job Card//
//////////////////////////
////////////////////////////
// Check for Short Leave//
//////////////////////////
foreach (var sLeave in _lvShort.Where(aa => aa.EmpDate == att.EmpDate))
{
if (_lvShort.Where(lv => lv.EmpDate == att.EmpDate).Count() > 0)
{
att.StatusSL = true;
att.StatusAB = null;
att.DutyCode = "L";
att.Remarks = "[Short Leave]";
}
}
//////////////////////////
// Check for Leave //
////////////////////////
//Set DutyCode = R, StatusAB=false, StatusGZ = true, and Remarks=[GZ]
foreach (var Leave in _LvData)
{
var _Leave = _LvData.Where(lv => lv.EmpDate == att.EmpDate && lv.HalfLeave != true);
if (_Leave.Count() > 0)
{
att.StatusLeave = true;
att.StatusAB = false;
att.DutyCode = "L";
att.StatusDO = false;
if (Leave.LvCode == "A")
att.Remarks = "[CL]";
else if (Leave.LvCode == "B")
att.Remarks = "[AL]";
else if (Leave.LvCode == "C")
att.Remarks = "[SL]";
else
att.Remarks = "[" + _Leave.FirstOrDefault().LvType.LvDesc + "]";
}
else
{
att.StatusLeave = false;
}
}
//////////////////////////
//Check for Half Leave///
/////////////////////////
var _HalfLeave = _LvData.Where(lv => lv.EmpDate == att.EmpDate && lv.HalfLeave == true);
if (_HalfLeave.Count() > 0)
{
att.StatusLeave = true;
att.StatusAB = false;
att.DutyCode = "L";
att.StatusHL = true;
att.StatusDO = false;
if (_HalfLeave.FirstOrDefault().LvCode == "A")
att.Remarks = "[H-CL]";
else if (_HalfLeave.FirstOrDefault().LvCode == "B")
att.Remarks = "[S-AL]";
else if (_HalfLeave.FirstOrDefault().LvCode == "C")
att.Remarks = "[H-SL]";
else
att.Remarks = "[Half Leave]";
}
else
{
att.StatusLeave = false;
}
ctx.SaveChanges();
}
catch (Exception ex)
{
}
}
}
ctx.Dispose();
}
}
示例15: CalculateTimeINOUTOpenShift
//.........这里部分代码省略.........
else if (attendanceRecord.Tin1 == null)
{
attendanceRecord.Tin1 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin2 == null)
{
attendanceRecord.Tin2 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin3 == null)
{
attendanceRecord.Tin3 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin4 == null)
{
attendanceRecord.Tin4 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin5 == null)
{
attendanceRecord.Tin5 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin6 == null)
{
attendanceRecord.Tin6 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin7 == null)
{
attendanceRecord.Tin7 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin8 == null)
{
attendanceRecord.Tin8 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin9 == null)
{
attendanceRecord.Tin9 = up.EntTime;
SortingInTime(attendanceRecord);
}
else if (attendanceRecord.Tin10 == null)
{
attendanceRecord.Tin10 = up.EntTime;
SortingInTime(attendanceRecord);
}
else
{
attendanceRecord.Tin11 = up.EntTime;
SortingInTime(attendanceRecord);
}
break;
case 5: //OUT
if (up.EntTime.TimeOfDay < OpenShiftThresholdEnd)
{
DateTime dt = up.EntDate.AddDays(-1);
if (context.AttDatas.Where(aa => aa.AttDate == dt && aa.EmpID == up.EmpID).Count() > 0)
{
AttData AttDataOfPreviousDay = context.AttDatas.FirstOrDefault(aa => aa.AttDate == dt && aa.EmpID == up.EmpID);
if (AttDataOfPreviousDay.TimeIn != null)
{
if (AttDataOfPreviousDay.TimeIn.Value.TimeOfDay > OpenShiftThresholdStart)
{
//AttDate -1, Possible TimeOut = up.entryTime
MarkOUTForOpenShift(up.EntTime, AttDataOfPreviousDay);
}
else
{
// Mark as out of that day
MarkOUTForOpenShift(up.EntTime, attendanceRecord);
}
}
else
MarkOUTForOpenShift(up.EntTime, attendanceRecord);
}
else
{
// Mark as out of that day
MarkOUTForOpenShift(up.EntTime, attendanceRecord);
}
}
else
{
//Mark as out of that day
MarkOUTForOpenShift(up.EntTime, attendanceRecord);
}
//-------------------------------------------------------
context.SaveChanges();
break;
}
}
catch (Exception ex)
{
}
}