protected void Apply_Click(object sender, DirectEventArgs e) { try { if (ApprovalStatusId.SelectedItem.Value == null && DamageLevelId.SelectedItem.Value == null && justification.Text == "") { if (ApprovalStatusId.SelectedItem.Value == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectApproval")).Show(); return; } else if (DamageLevelId.SelectedItem.Value == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("SelectDamage")).Show(); return; } else if (justification.Text == null) { X.Msg.Alert(Resources.Common.Error, (string)GetLocalResourceObject("FillJustification")).Show(); return; } } else { string rep_params = vals.Text; //ReportGenericRequest req = new ReportGenericRequest(); TVListRequest req = new TVListRequest(); req.paramString = rep_params; req.size = "5000"; req.startAt = "0"; req.sortBy = "date,employeeRef"; ListResponse <DashBoardTimeVariation3> daysResponse = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation3>(req); if (!daysResponse.Success) { Common.errorMessage(daysResponse); return; } DashBoardTimeVariation b = new DashBoardTimeVariation(); if (daysResponse.Items.Count > 0) { daysResponse.Items.ForEach( x => { b.apId = x.apId; if (ApprovalStatusId.SelectedItem.Value == null) { b.apStatus = x.apStatus; b.apStatusString = x.apStatusString; } else { b.apStatus = Convert.ToInt16(ApprovalStatusId.SelectedItem.Value); b.apStatusString = ApprovalStatusId.SelectedItem.Text; } b.branchName = x.branchName; b.clockDuration = x.clockDuration; b.clockDurationString = x.clockDurationString; if (arId.SelectedItem.Value == null) { b.arId = x.arId; } else { b.arId = arId.SelectedItem.Value; } if (DamageLevelId.SelectedItem.Value == null) { b.damageLevel = x.damageLevel; b.damageLevelString = x.damageLevelString; } else { b.damageLevel = Convert.ToInt16(DamageLevelId.SelectedItem.Value); b.damageLevelString = DamageLevelId.SelectedItem.Text; } b.date = x.date; b.dayId = x.dayId; b.dayIdDate = x.dayIdDate; b.dayIdString = x.dayIdString; b.dtFrom = x.dtFrom; b.dtTo = x.dtTo; b.duration = x.duration; b.durationString = x.durationString; b.employeeId = x.employeeId; b.employeeName = x.employeeName; b.employeeRef = x.employeeRef; if (justification.Text == "") { b.justification = x.justification; } else { b.justification = justification.Text; } b.positionName = x.positionName; //b.primaryKey = x.primaryKey; b.recordId = x.recordId; b.shiftId = x.shiftId; b.timeCode = x.timeCode; b.timeCodeString = x.timeCodeString; PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>(); request.entity = b; PostResponse <DashBoardTimeVariation> response = _timeAttendanceService.ChildAddOrUpdate <DashBoardTimeVariation>(request); if (!response.Success) //it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } } ); //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection())); } } } catch (Exception exp) { X.MessageBox.Alert(Resources.Common.Error, exp.Message); } //ReloadData(new object(), new DirectEventArgs(new Ext.Net.ParameterCollection())); Store1.RemoveAll(); }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; DashBoardTimeVariation b = JsonConvert.DeserializeObject <DashBoardTimeVariation>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null try { //getting the id of the record TimeVariationListRequest req = new TimeVariationListRequest(); ListResponse <DashBoardTimeVariation> r = _timeAttendanceService.ChildGetAll <DashBoardTimeVariation>(req); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { if (r.Items.Where(x => x.primaryKey == id).Count() == 0) { return; } else { PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>(); request.entity = r.Items.Where(x => x.primaryKey == id).First(); request.entity.damageLevel = Convert.ToInt16(damage.Value); request.entity.duration = Convert.ToInt16(duration.Text); PostResponse <DashBoardTimeVariation> response = _timeAttendanceService.ChildAddOrUpdate <DashBoardTimeVariation>(request); if (!response.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } } } Store1.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; DashBoardTimeVariation b = JsonConvert.DeserializeObject <DashBoardTimeVariation>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null try { //getting the id of the record RecordRequest req = new RecordRequest(); req.RecordID = id; RecordResponse <DashBoardTimeVariation> r = _timeAttendanceService.ChildGetRecord <DashBoardTimeVariation>(req); //Step 1 Selecting the object or building up the object for update purpose if (!r.Success) { Common.errorMessage(r); return; } if (r.result != null) { PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>(); request.entity = r.result; request.entity.damageLevel = Convert.ToInt16(damage.Value); request.entity.duration = Convert.ToInt16(duration.Text); request.entity.justification = b.justification; request.entity.arId = TimeApprovalReasonControl.getApprovalReason() == "0"?null: TimeApprovalReasonControl.getApprovalReason(); PostResponse <DashBoardTimeVariation> response = _timeAttendanceService.ChildAddOrUpdate <DashBoardTimeVariation>(request); if (!response.Success) //it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } } Store1.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } }
protected void SaveNewRecord(object sender, DirectEventArgs e) { //Getting the id to check if it is an Add or an edit as they are managed within the same form. string obj = e.ExtraParams["values"]; DashBoardTimeVariation b = JsonConvert.DeserializeObject <DashBoardTimeVariation>(obj); string id = e.ExtraParams["id"]; // Define the object to add or edit as null try { //getting the id of the record TimeVariationListRequest req1 = GetAbsentRequest(); string rep_params = ""; Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("1", req1.employeeId); parameters.Add("2", req1.fromDayId.ToString("yyyyMMdd")); parameters.Add("3", req1.toDayId.ToString("yyyyMMdd")); parameters.Add("4", "0"); parameters.Add("5", req1.timeCode); parameters.Add("6", req1.apStatus); parameters.Add("7", req1.BranchId); parameters.Add("8", req1.DepartmentId); parameters.Add("9", req1.EsId); foreach (KeyValuePair <string, string> entry in parameters) { rep_params += entry.Key.ToString() + "|" + entry.Value + "^"; } if (rep_params.Length > 0) { if (rep_params[rep_params.Length - 1] == '^') { rep_params = rep_params.Remove(rep_params.Length - 1); } } ReportGenericRequest req = new ReportGenericRequest(); req.paramString = rep_params; ListResponse <DashBoardTimeVariation> r = _selfServiceService.ChildGetAll <DashBoardTimeVariation>(req); //Step 1 Selecting the object or building up the object for update purpose //Step 2 : saving to store //Step 3 : Check if request fails if (!r.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(r);; return; } else { if (r.Items.Where(x => x.recordId == id).Count() == 0) { return; } else { PostRequest <DashBoardTimeVariation> request = new PostRequest <DashBoardTimeVariation>(); request.entity = r.Items.Where(x => x.recordId == id).First(); request.entity.damageLevel = Convert.ToInt16(damage.Value); request.entity.duration = Convert.ToInt16(duration.Text); request.entity.justification = b.justification; // request.entity.recordId = null; PostResponse <DashBoardTimeVariation> response = _selfServiceService.ChildAddOrUpdate <DashBoardTimeVariation>(request); if (!response.Success)//it maybe another check { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; Common.errorMessage(response); return; } } } Store1.Reload(); Notification.Show(new NotificationConfig { Title = Resources.Common.Notification, Icon = Icon.Information, Html = Resources.Common.RecordUpdatedSucc }); this.EditRecordWindow.Close(); } catch (Exception ex) { X.MessageBox.ButtonText.Ok = Resources.Common.Ok; X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show(); } }