Пример #1
0
        protected void AutomarkCalls_Clicked(object sender, DirectEventArgs e)
        {
            List <PhoneCall> userSessionPhoneCalls;
            Dictionary <string, PhoneBookContact> userSessionAddressbook;
            PhoneBookContact addressBookEntry;
            int numberOfRemainingUnmarked;

            //Get the unmarked calls from the user session phonecalls container
            CurrentSession.FetchSessionPhonecallsAndAddressbookData(out userSessionPhoneCalls, out userSessionAddressbook);

            numberOfRemainingUnmarked = userSessionPhoneCalls.Where(phoneCall => string.IsNullOrEmpty(phoneCall.UiCallType)).ToList().Count;

            //If the user has no addressbook contacts, skip the auto marking process
            if (userSessionAddressbook.Keys.Count > 0)
            {
                foreach (var phoneCall in userSessionPhoneCalls.Where(phoneCall => string.IsNullOrEmpty(phoneCall.UiCallType)))
                {
                    if (userSessionAddressbook.Keys.Contains(phoneCall.DestinationNumberUri))
                    {
                        addressBookEntry = (PhoneBookContact)userSessionAddressbook[phoneCall.DestinationNumberUri];

                        if (!string.IsNullOrEmpty(addressBookEntry.Type))
                        {
                            phoneCall.UiCallType      = addressBookEntry.Type;
                            phoneCall.UiUpdatedByUser = sipAccount;
                            phoneCall.UiMarkedOn      = DateTime.Now;

                            Global.DATABASE.PhoneCalls.Update(phoneCall, phoneCall.PhoneCallsTableName);

                            ModelProxy model = MyPhoneCallsGrid.GetStore().Find("SessionIdTime", phoneCall.SessionIdTime.ToString());
                            model.Set(phoneCall);
                            model.Commit();
                        }
                    }
                }
            }

            MyPhoneCallsGrid.GetSelectionModel().DeselectAll();
            MyPhoneCallsGrid.GetStore().LoadPage(1);

            CurrentSession.AssignSessionPhonecallsAndAddressbookData(userSessionPhoneCalls, userSessionAddressbook);
        }
Пример #2
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            string ExpiryDateString    = e.ExtraParams["rwExpiryDate"];
            string IssueDateDateString = e.ExtraParams["rwIssueDate"];

            DateTime ExpiryDate = new DateTime();
            DateTime IssueDate  = new DateTime();

            if (!string.IsNullOrEmpty(ExpiryDateString))
            {
                ExpiryDate = DateTime.Parse(e.ExtraParams["rwExpiryDate"]);
            }
            if (!string.IsNullOrEmpty(IssueDateDateString))
            {
                IssueDate = DateTime.Parse(e.ExtraParams["rwIssueDate"]);
            }

            //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"];
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.NullValueHandling = NullValueHandling.Ignore;
            CompanyRightToWork b = JsonConvert.DeserializeObject <CompanyRightToWork>(obj, settings);

            string id  = e.ExtraParams["id"];
            string url = e.ExtraParams["url"];

            // Define the object to add or edit as null

            if (dtId.SelectedItem != null)
            {
                b.dtName = dtId.SelectedItem.Text;
            }

            if (branchId.SelectedItem != null)
            {
                b.branchName = branchId.SelectedItem.Text;
            }
            bool hijriSupported = _systemService.SessionHelper.GetHijriSupport();

            try
            {
                CultureInfo c      = new CultureInfo("en");
                string      format = "";
                if (hijriSupported)
                {
                    if (hijriSelected.Text == "true")
                    {
                        b.hijriCal   = true;
                        c            = new CultureInfo("ar");
                        format       = "yyyy/MM/dd";
                        b.issueDate  = DateTime.ParseExact(rwIssueDateMulti.Text, format, c);
                        b.expiryDate = DateTime.ParseExact(rwExpiryDateMulti.Text, format, c);
                    }
                    //else
                    //{
                    //    c = new CultureInfo("en");
                    //    if (_systemService.SessionHelper.CheckIfArabicSession())
                    //    {

                    //        format = "dd/MM/yyyy";
                    //    }
                    //    else
                    //    {
                    //        format = "MM/dd/yyyy";
                    //    }
                    //}
                    else
                    {
                        b.issueDate = IssueDate;


                        b.expiryDate = ExpiryDate;
                    }
                }
            }
            catch (Exception exp)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("DateFormatError")).Show();

                return;
            }
            //b.remarks =
            if (b.issueDate != null && (b.issueDate > b.expiryDate))
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("DateRangeError")).Show();

                return;
            }

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store

                    PostRequest <CompanyRightToWork> request = new PostRequest <CompanyRightToWork>();
                    request.entity = b;
                    byte[] fileData = null;
                    if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0)
                    {
                        //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        //{
                        //    fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        //}
                        fileData = new byte[rwFile.PostedFile.ContentLength];
                        fileData = rwFile.FileBytes;
                    }



                    PostResponse <CompanyRightToWork> r = _systemService.ChildAddOrUpdate <CompanyRightToWork>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        if (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.SYRW, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0
                            };
                            req.FileNames.Add(rwFile.PostedFile.FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                Common.errorMessage(r);
                                return;
                            }
                        }
                        b.recordId = r.recordId;
                        //Add this record to the store
                        CompanyRightToWork m = GetRWById(r.recordId);
                        Store1.Insert(0, m);
                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <CompanyRightToWork> request = new PostRequest <CompanyRightToWork>();
                    b.recordId     = index.ToString();;
                    request.entity = b;

                    byte[] fileData = null;
                    if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0)
                    {
                        fileData = new byte[rwFile.PostedFile.ContentLength];
                        fileData = rwFile.FileBytes;
                    }


                    PostResponse <CompanyRightToWork> r = _systemService.ChildAddOrUpdate <CompanyRightToWork>(request);                      //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 (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.SYRW, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0
                            };
                            req.FileNames.Add(rwFile.PostedFile.FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                Common.errorMessage(r);
                                return;
                            }
                        }
                        CompanyRightToWork m = GetRWById(id);

                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);
                        record.Set("dtName", b.dtName);
                        record.Set("branchName", b.branchName);
                        record.Set("fileUrl", m.fileUrl);
                        record.Set("issueDateFormatted", m.issueDateFormatted);
                        record.Set("expireDateFormatted", m.expireDateFormatted);
                        record.Commit();
                        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();
                }
            }
        }
Пример #3
0
        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 id = e.ExtraParams["id"];

            string obj  = e.ExtraParams["values"];
            string addr = e.ExtraParams["address"];
            Branch b    = JsonConvert.DeserializeObject <Branch>(obj);

            b.managerId = managerId.Value.ToString();

            b.isInactive   = isInactive.Checked;
            b.activeStatus = isInactive.Checked ? Convert.ToInt16(ActiveStatus.INACTIVE) : Convert.ToInt16(ActiveStatus.ACTIVE);
            b.recordId     = id;
            // Define the object to add or edit as null
            CustomResolver res = new CustomResolver();

            res.AddRule("naId", "countryId");
            res.AddRule("stId", "stateId");
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ContractResolver = res;
            b.caName = caId.SelectedItem.Text;
            AddressBook add = JsonConvert.DeserializeObject <AddressBook>(addr, settings);

            if (string.IsNullOrEmpty(add.city) && string.IsNullOrEmpty(add.countryId) && string.IsNullOrEmpty(add.street1) && string.IsNullOrEmpty(add.stateId) && string.IsNullOrEmpty(add.phone))
            {
                b.address = null;
            }
            else
            {
                if (string.IsNullOrEmpty(add.city) || string.IsNullOrEmpty(add.countryId) || string.IsNullOrEmpty(add.street1) || string.IsNullOrEmpty(add.stateId) || string.IsNullOrEmpty(add.phone))
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorAddressMissing")).Show();
                    return;
                }
                b.address          = JsonConvert.DeserializeObject <AddressBook>(addr, settings);
                b.address.recordId = address.Text;
            }

            if (string.IsNullOrEmpty(branchId.Text))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <Branch> request = new PostRequest <Branch>();
                    request.entity = b;
                    PostResponse <Branch> r = _branchService.ChildAddOrUpdate <Branch>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId :r.Summary).Show();
                        return;
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(branchId.Text))
                        {
                            //this.Store1.Insert(0, b);


                            this.EditRecordWindow.Close();
                            //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                            //sm.DeselectAll();
                            //sm.Select(b.recordId.ToString());
                        }

                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                        //Add this record to the store
                        managerId.Disabled = false;

                        //Display successful notification
                        branchId.Text = b.recordId;
                        Store1.Reload();
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(branchId.Text);//getting the id of the record
                    PostRequest <Branch> request = new PostRequest <Branch>();
                    b.recordId     = branchId.Text;
                    request.entity = b;
                    PostResponse <Branch> r = _branchService.ChildAddOrUpdate <Branch>(request);                      //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
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        record.Set("caName", b.caName);
                        BasicInfoTab.UpdateRecord(record);

                        record.Commit();
                        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();
                }
            }
        }
Пример #4
0
        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 id = e.ExtraParams["id"];

            string             obj = e.ExtraParams["schedule"];
            AttendanceSchedule b   = JsonConvert.DeserializeObject <AttendanceSchedule>(obj);

            if (!b.fci_max_lt.HasValue)
            {
                b.fci_max_lt = 0;
            }
            if (!b.fci_min_ot.HasValue)
            {
                b.fci_min_ot = 0;
            }
            if (!b.lco_max_el.HasValue)
            {
                b.lco_max_el = 0;
            }
            if (!b.lco_max_ot.HasValue)
            {
                b.lco_max_ot = 0;
            }
            if (!b.lco_min_ot.HasValue)
            {
                b.lco_min_ot = 0;
            }
            b.recordId = id;
            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <AttendanceSchedule> request = new PostRequest <AttendanceSchedule>();
                    request.entity = b;
                    PostResponse <AttendanceSchedule> r = _branchService.ChildAddOrUpdate <AttendanceSchedule>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }



                    else
                    {
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                        //   setDefaultBtn.Hidden = false;
                        recordId.Text = b.recordId;

                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <AttendanceSchedule> modifyHeaderRequest = new PostRequest <AttendanceSchedule>();
                    modifyHeaderRequest.entity = b;
                    PostResponse <AttendanceSchedule> r = _branchService.ChildAddOrUpdate <AttendanceSchedule>(modifyHeaderRequest); //Step 1 Selecting the object or building up the object for update purpose
                    if (!r.Success)                                                                                                  //it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }

                    //Step 2 : saving to store


                    else
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        BasicInfoTab.UpdateRecord(record);

                        record.Commit();
                        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();
                }
            }
        }
Пример #5
0
        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"];
            Case   b   = JsonConvert.DeserializeObject <Case>(obj);

            string id = e.ExtraParams["id"];

            // Define the object to add or edit as null

            //b.employeeName = new EmployeeName();
            if (employeeId.SelectedItem != null)
            {
                b.employeeName = employeeId.SelectedItem.Text;
            }

            if (closedDate.ReadOnly)
            {
                b.closedDate = null;
            }
            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <Case> request = new PostRequest <Case>();

                    request.entity = b;

                    PostResponse <Case> r = _caseService.AddOrUpdate <Case>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                        return;
                    }
                    else
                    {
                        b.recordId = r.recordId;

                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                        recordId.Text = b.recordId;
                        SetTabPanelEnable(true);
                        currentCase.Text = b.recordId;
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <Case> request = new PostRequest <Case>();
                    request.entity = b;
                    PostResponse <Case> r = _caseService.AddOrUpdate <Case>(request);                      //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;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);

                        if (closedDate.ReadOnly)
                        {
                            record.Set("closedDate", null);
                        }
                        record.Set("employeeName", b.employeeName);
                        record.Commit();
                        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();
                }
            }
        }
Пример #6
0
        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 id = e.ExtraParams["id"];

            string        obj  = e.ExtraParams["schedule"];
            LeaveSchedule b    = JsonConvert.DeserializeObject <LeaveSchedule>(obj);
            string        pers = e.ExtraParams["periods"];

            b.recordId = id;
            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <LeaveSchedule> request = new PostRequest <LeaveSchedule>();
                    request.entity = b;
                    PostResponse <LeaveSchedule> r = _branchService.ChildAddOrUpdate <LeaveSchedule>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    List <LeaveSchedulePeriod> periods = JsonConvert.DeserializeObject <List <LeaveSchedulePeriod> >(pers);
                    bool Success = AddPeriodsList(b.recordId, periods);


                    if (Success)
                    {
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <LeaveSchedule> modifyHeaderRequest = new PostRequest <LeaveSchedule>();
                    modifyHeaderRequest.entity = b;
                    PostResponse <LeaveSchedule> r = _branchService.ChildAddOrUpdate <LeaveSchedule>(modifyHeaderRequest); //Step 1 Selecting the object or building up the object for update purpose
                    if (!r.Success)                                                                                        //it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }
                    LeaveSchedulesListRequest leaveScheduleReq = new LeaveSchedulesListRequest();
                    leaveScheduleReq.LeaveScheduleId = b.recordId;
                    ListResponse <LeaveSchedulePeriod> leaveScheduleResponse = _branchService.ChildGetAll <LeaveSchedulePeriod>(leaveScheduleReq);

                    leaveScheduleResponse.Items.ForEach(x =>
                    {
                        PostRequest <LeaveSchedulePeriod> LeaveScheduleDEleteRequest = new PostRequest <LeaveSchedulePeriod>();
                        LeaveScheduleDEleteRequest.entity = x;
                        PostResponse <LeaveSchedulePeriod> LeaveScheduleDEleteResponse = _branchService.ChildDelete <LeaveSchedulePeriod>(LeaveScheduleDEleteRequest);
                        if (!LeaveScheduleDEleteResponse.Success)
                        {
                            Common.errorMessage(LeaveScheduleDEleteResponse);
                            throw new Exception();
                        }
                    });

                    List <LeaveSchedulePeriod> periods = JsonConvert.DeserializeObject <List <LeaveSchedulePeriod> >(pers);
                    bool result = AddPeriodsList(b.recordId, periods);

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (result)
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        BasicInfoTab.UpdateRecord(record);

                        record.Commit();
                        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();
                }
            }
        }
Пример #7
0
        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"];
            JsonSerializerSettings s = new JsonSerializerSettings();

            s.NullValueHandling = NullValueHandling.Ignore;
            Geofence b = JsonConvert.DeserializeObject <Geofence>(obj, s);

            if (branchId.SelectedItem != null)
            {
                b.branchName = branchId.SelectedItem.Text;
            }

            string id = e.ExtraParams["id"];

            b.shape = (short)(e.ExtraParams["isCircle"] == "true"?1:0);
            b.lat   = Convert.ToDouble(e.ExtraParams["lat1"]);
            b.lon   = Convert.ToDouble(e.ExtraParams["lon1"]);
            if (b.shape == 1)
            {
                b.radius = Convert.ToDouble(e.ExtraParams["radius"]);
                b.lat2   = 0;
                b.lon2   = 0;
            }
            else
            {
                b.lat2   = Convert.ToDouble(e.ExtraParams["lat2"]);
                b.lon2   = Convert.ToDouble(e.ExtraParams["lon2"]);
                b.radius = 0;
            }

            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <Geofence> request = new PostRequest <Geofence>();

                    request.entity = b;
                    PostResponse <Geofence> r = _timeAttendanceService.ChildAddOrUpdate <Geofence>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        b.recordId = r.recordId;
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <Geofence> request = new PostRequest <Geofence>();
                    request.entity = b;
                    PostResponse <Geofence> r = _timeAttendanceService.ChildAddOrUpdate <Geofence>(request);                      //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;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);
                        record.Set("branchName", b.branchName);
                        record.Commit();
                        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();
                }
            }
        }
Пример #8
0
        protected void SaveFolder(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 id = e.ExtraParams["id"];

            string      obj = e.ExtraParams["values"];
            Attachement b   = JsonConvert.DeserializeObject <Attachement>(obj);

            b.recordId = 0;
            b.seqNo    = Convert.ToInt16(id);
            b.classId  = ClassId.DMDO;
            b.fileName = fileName.Text;
            // Define the object to add or edit as null
            b.folderName = folderId.SelectedItem.Text;


            try
            {
                //New Mode
                PostRequest <Attachement> req = new PostRequest <Attachement>();
                req.entity = b;



                PostResponse <Attachement> r = _systemService.ChildAddOrUpdate <Attachement>(req);



                //check if the insert failed
                if (!r.Success)//it maybe be another condition
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(r);
                    return;
                }
                else
                {
                    ModelProxy record = this.Store1.GetById(id);

                    EditDocumentForm.UpdateRecord(record);
                    record.Set("folderName", b.folderName);


                    record.Commit();
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordUpdatedSucc
                    });
                    this.EditDocumentWindow.Close();
                }
            }
            catch (Exception ex)
            {
                //Error exception displaying a messsage box
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
            }
        }
Пример #9
0
        protected void SaveDayBreaks(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 dayJ    = e.ExtraParams["day"];
            string breaksJ = e.ExtraParams["breaks"];

            AttendanceScheduleDay day     = JsonConvert.DeserializeObject <AttendanceScheduleDay>(dayJ);
            bool workingDay               = IsWorkingDay.Text == "True";
            List <AttendanceBreak> breaks = null;

            if (workingDay)
            {
                breaks = JsonConvert.DeserializeObject <List <AttendanceBreak> >(breaksJ);
            }
            else
            {
                day.firstIn = "00:00";
                day.lastOut = "00:00";
            }
            day.scId = Convert.ToInt32(e.ExtraParams["scId"]);
            day.dow  = Convert.ToInt16(CurrentDow.Text);

            // Define the object to add or edit as null



            try
            {
                //getting the id of the record
                PostRequest <AttendanceScheduleDay> modifyHeaderRequest = new PostRequest <AttendanceScheduleDay>();
                modifyHeaderRequest.entity = day;
                PostResponse <AttendanceScheduleDay> r = _branchService.ChildAddOrUpdate <AttendanceScheduleDay>(modifyHeaderRequest); //Step 1 Selecting the object or building up the object for update purpose
                if (!r.Success)                                                                                                        //it maybe another check
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                    return;
                }
                if (workingDay)
                {
                    PostResponse <AttendanceBreak> deleteResponse = _branchService.DeleteDayBreaks(day.scId, day.dow);
                    if (!deleteResponse.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, deleteResponse.Summary).Show();
                        return;
                    }
                    try

                    {
                        AddBreaksList(day.scId.ToString(), day.dow, breaks);
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                }



                ModelProxy record = this.scheduleStore.GetById(day.dow);
                dayBreaksForm.UpdateRecord(record);
                if (!workingDay)
                {
                    record.Set("firstIn", "00:00");
                    record.Set("lastOut", "00:00");
                }
                record.Commit();
                Notification.Show(new NotificationConfig
                {
                    Title = Resources.Common.Notification,
                    Icon  = Icon.Information,
                    Html  = Resources.Common.RecordUpdatedSucc
                });
                this.EditDayBreaks.Close();
            }
            catch (Exception ex)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }
Пример #10
0
        protected void SaveJI(object sender, DirectEventArgs e)
        {
            try
            {
                //Getting the id to check if it is an Add or an edit as they are managed within the same form.
                string id = e.ExtraParams["id"];

                string  obj = e.ExtraParams["values"];
                JobInfo b   = JsonConvert.DeserializeObject <JobInfo>(obj);
                b.employeeId = Convert.ToInt32(CurrentEmployee.Text);
                b.recordId   = id;
                b.date       = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0);



                if (branchId.SelectedItem != null)
                {
                    b.branchName = branchId.SelectedItem.Text;
                }
                if (departmentId.SelectedItem != null)
                {
                    b.departmentName = departmentId.SelectedItem.Text;
                }
                if (positionId.SelectedItem != null)
                {
                    b.positionName = positionId.SelectedItem.Text;
                }
                if (divisionId.SelectedItem != null)
                {
                    b.divisionName = divisionId.SelectedItem.Text;
                }

                // b.reportToName = new EmployeeName();
                if (reportToId.SelectedItem != null)
                {
                    b.reportToName = reportToId.SelectedItem.Text;
                }
                // Define the object to add or edit as null
                if (b.reportToId == 0)
                {
                    b.reportToId = null;
                }
                if (string.IsNullOrEmpty(id))
                {
                    try
                    {
                        //New Mode
                        //Step 1 : Fill The object and insert in the store
                        PostRequest <JobInfo> request = new PostRequest <JobInfo>();
                        request.entity = b;
                        PostResponse <JobInfo> r = _employeeService.ChildAddOrUpdate <JobInfo>(request);
                        b.recordId = r.recordId;

                        //check if the insert failed
                        if (!r.Success)//it maybe be another condition
                        {
                            //Show an error saving...
                            X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                            Common.errorMessage(r);;
                            return;
                        }
                        else
                        {
                            //Add this record to the store

                            JIStore.Reload();

                            //Display successful notification
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordSavingSucc
                            });

                            this.EditJobInfoWindow.Close();
                            RowSelectionModel sm = this.JobInfoGrid.GetSelectionModel() as RowSelectionModel;
                            sm.DeselectAll();
                            sm.Select(b.recordId.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        //Error exception displaying a messsage box
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                    }
                }
                else
                {
                    //Update Mode

                    try
                    {
                        int index = Convert.ToInt32(id);//getting the id of the record
                        PostRequest <JobInfo> request = new PostRequest <JobInfo>();
                        request.entity = b;
                        PostResponse <JobInfo> r = _employeeService.ChildAddOrUpdate <JobInfo>(request);                      //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
                        {
                            ModelProxy record = this.JIStore.GetById(index);
                            EditJobInfoTab.UpdateRecord(record);
                            record.Set("departmentName", b.departmentName);
                            record.Set("branchName", b.branchName);
                            record.Set("positionName", b.positionName);
                            record.Set("divisionName", b.divisionName);
                            record.Set("reportToName", b.reportToName);
                            record.Commit();
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordUpdatedSucc
                            });
                            JIStore.Reload();
                            this.EditJobInfoWindow.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                    }
                }

                X.Call("parent.refreshQV");
                X.Call("parent.SetJobInfo", b.departmentId, b.branchId, b.positionId, b.divisionId, b.reportToId);
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, exp.Message).Show();
            }
        }
Пример #11
0
        protected void SaveEH(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 id = e.ExtraParams["id"];

            string            obj = e.ExtraParams["values"];
            EmploymentHistory b   = JsonConvert.DeserializeObject <EmploymentHistory>(obj);

            b.employeeId = Convert.ToInt32(CurrentEmployee.Text);
            b.recordId   = id;
            // Define the object to add or edit as null
            b.statusName = statusId.SelectedItem.Text;
            b.date       = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0);

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <EmploymentHistory> request = new PostRequest <EmploymentHistory>();
                    request.entity = b;
                    PostResponse <EmploymentHistory> r = _employeeService.ChildAddOrUpdate <EmploymentHistory>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        this.employeementHistoryStore.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditEHwindow.Close();
                        RowSelectionModel sm = this.employeementHistoryGrid.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                        EHCount.Text = (Convert.ToInt32(EHCount.Text) + 1).ToString();
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <EmploymentHistory> request = new PostRequest <EmploymentHistory>();
                    request.entity = b;
                    PostResponse <EmploymentHistory> r = _employeeService.ChildAddOrUpdate <EmploymentHistory>(request);                      //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
                    {
                        ModelProxy record = this.employeementHistoryStore.GetById(index);
                        record.Set("date", b.date.ToShortDateString());
                        record.Set("statusName", b.statusName);
                        EditEHForm.UpdateRecord(record);
                        record.Commit();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditEHwindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
            X.Call("parent.refreshQV");
        }
Пример #12
0
        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 id = e.ExtraParams["id"];

            string   obj = e.ExtraParams["values"];
            Employee b   = JsonConvert.DeserializeObject <Employee>(obj);

            b.name = new EmployeeName()
            {
                firstName = firstName.Text, lastName = lastName.Text, familyName = familyName.Text, middleName = middleName.Text
            };
            b.isInactive = isInactive.Checked;
            b.recordId   = id;
            // Define the object to add or edit as null
            if (branchId.SelectedItem != null)
            {
                b.branchName = branchId.SelectedItem.Text;
            }
            if (departmentId.SelectedItem != null)
            {
                b.departmentName = departmentId.SelectedItem.Text;
            }
            if (positionId.SelectedItem != null)
            {
                b.positionName = positionId.SelectedItem.Text;
            }
            b.name.fullName = b.name.firstName + " " + b.name.middleName + " " + b.name.lastName + " ";
            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    EmployeeAddOrUpdateRequest request = new EmployeeAddOrUpdateRequest();

                    byte[] fileData = null;
                    if (picturePath.PostedFile != null && picturePath.PostedFile.ContentLength > 0)
                    {
                        using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        {
                            fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        }
                        request.fileName  = picturePath.PostedFile.FileName;
                        request.imageData = fileData;
                    }
                    else
                    {
                        request.imageData = fileData;
                        request.fileName  = "";
                    }
                    request.empData = b;



                    PostResponse <Employee> r = _employeeService.AddOrUpdateEmployeeWithPhoto(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    EmployeeAddOrUpdateRequest request = new EmployeeAddOrUpdateRequest();

                    byte[] fileData = null;
                    if (picturePath.HasFile && picturePath.PostedFile.ContentLength > 0)
                    {
                        //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        // {
                        //    fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        // }
                        fileData          = new byte[picturePath.PostedFile.ContentLength];
                        fileData          = picturePath.FileBytes;
                        request.fileName  = picturePath.PostedFile.FileName;
                        request.imageData = fileData;
                    }
                    else
                    {
                        request.imageData = fileData;
                        request.fileName  = "";
                    }
                    request.empData = b;



                    PostResponse <Employee> r = _employeeService.AddOrUpdateEmployeeWithPhoto(request);

                    //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;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        //BasicInfoTab.UpdateRecord(record);
                        record.Set("branchName", b.branchName);
                        record.Set("departmentName", b.departmentName);
                        record.Set("positionName", b.positionName);
                        record.Set("name", b.name);
                        record.Set("reference", b.reference);
                        record.Set("hireDate", b.hireDate.Value.ToShortDateString());
                        record.Commit();
                        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();
                }
            }
        }
Пример #13
0
        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"];
            MediaItem b   = JsonConvert.DeserializeObject <MediaItem>(obj);

            string id  = e.ExtraParams["id"];
            string url = e.ExtraParams["url"];

            // Define the object to add or edit as null

            if (mcId.SelectedItem != null)
            {
                b.mcName = mcId.SelectedItem.Text;
            }

            if (departmentId.SelectedItem != null)
            {
                b.departmentName = departmentId.SelectedItem.Text;
            }


            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store

                    PostRequest <MediaItem> request = new PostRequest <MediaItem>();
                    request.entity = b;
                    byte[] fileData = null;
                    if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0)
                    {
                        //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        //{
                        //    fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        //}
                        fileData = new byte[rwFile.PostedFile.ContentLength];
                        fileData = rwFile.FileBytes;
                    }



                    PostResponse <MediaItem> r = _mediaGalleryService.ChildAddOrUpdate <MediaItem>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                        return;
                    }
                    else
                    {
                        if (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.MGME, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = null
                            };
                            req.FileNames.Add(rwFile.PostedFile.FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                                return;
                            }
                        }
                        b.recordId = r.recordId;
                        //Add this record to the store
                        MediaItem m = GetMEById(r.recordId);
                        Store1.Insert(0, m);
                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <MediaItem> request = new PostRequest <MediaItem>();
                    request.entity = b;
                    byte[] fileData = null;
                    if (rwFile.PostedFile != null && rwFile.PostedFile.ContentLength > 0)
                    {
                        fileData = new byte[rwFile.PostedFile.ContentLength];
                        fileData = rwFile.FileBytes;
                    }


                    PostResponse <MediaItem> r = _mediaGalleryService.ChildAddOrUpdate <MediaItem>(request);                      //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;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                        return;
                    }
                    else
                    {
                        if (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.MGME, recordId = Convert.ToInt32(b.recordId), fileName = rwFile.PostedFile.FileName, seqNo = 0
                            };
                            req.FileNames.Add(rwFile.PostedFile.FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", r.ErrorCode) != null ? GetGlobalResourceObject("Errors", r.ErrorCode).ToString() + "<br>" + GetGlobalResourceObject("Errors", "ErrorLogId") + r.LogId : r.Summary).Show();
                                return;
                            }
                        }
                        MediaItem m = GetMEById(id);

                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);
                        record.Set("mcName", b.mcName);
                        record.Set("departmentName", b.departmentName);
                        recordId.Set("pictureUrl", m.pictureUrl);
                        record.Commit();
                        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();
                }
            }
        }
Пример #14
0
        protected void SaveBC(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 id = e.ExtraParams["id"];

            string obj                = e.ExtraParams["values"];
            string bcFileURl          = e.ExtraParams["BcFile"];
            EmployeeBackgroundCheck b = JsonConvert.DeserializeObject <EmployeeBackgroundCheck>(obj);

            b.fileUrl = bcFileURl;
            if (!string.IsNullOrEmpty(b.fileUrl))
            {
                b.fileUrl = Regex.Replace(b.fileUrl, @"[^0-9a-zA-Z.]+", "");
            }
            b.employeeId = Convert.ToInt32(CurrentEmployee.Text);
            b.recordId   = id;
            b.date       = new DateTime(b.date.Year, b.date.Month, b.date.Day, 14, 0, 0);
            b.expiryDate = new DateTime(b.expiryDate.Year, b.expiryDate.Month, b.expiryDate.Day, 14, 0, 0);

            if (ctId.SelectedItem != null)
            {
                b.ctName = ctId.SelectedItem.Text;
            }

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <EmployeeBackgroundCheck> request = new PostRequest <EmployeeBackgroundCheck>();
                    request.entity = b;
                    byte[] fileData = null;
                    if (bcFile.PostedFile != null && bcFile.PostedFile.ContentLength > 0)
                    {
                        //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        //{
                        //    fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        //}
                        fileData = new byte[bcFile.PostedFile.ContentLength];
                        fileData = bcFile.FileBytes;
                    }
                    else
                    {
                        fileData = null;
                    }
                    PostResponse <EmployeeBackgroundCheck> r = _employeeService.ChildAddOrUpdate <EmployeeBackgroundCheck>(request);
                    b.recordId = r.recordId;

                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        if (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.EPBC, recordId = Convert.ToInt32(b.recordId), fileName = bcFile.PostedFile.FileName, seqNo = 0
                            };
                            req.FileNames.Add(bcFile.PostedFile.FileName);
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                Common.errorMessage(r);
                                return;
                            }
                        }
                        EmployeeBackgroundCheck bc = GetBCById(r.recordId);
                        this.BCStore.Insert(0, bc);
                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditBCWindow.Close();
                        RowSelectionModel sm = this.BackgroundCheckGrid.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <EmployeeBackgroundCheck> request = new PostRequest <EmployeeBackgroundCheck>();
                    request.entity = b;
                    byte[] fileData = null;

                    if (bcFile.PostedFile != null && bcFile.PostedFile.ContentLength > 0)
                    {
                        //using (var binaryReader = new BinaryReader(picturePath.PostedFile.InputStream))
                        //{
                        //    fileData = binaryReader.ReadBytes(picturePath.PostedFile.ContentLength);
                        //}
                        fileData = new byte[bcFile.PostedFile.ContentLength];
                        fileData = bcFile.FileBytes;
                    }

                    PostResponse <EmployeeBackgroundCheck> r = _employeeService.ChildAddOrUpdate <EmployeeBackgroundCheck>(request);                      //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 (fileData != null)
                        {
                            SystemAttachmentsPostRequest req = new SystemAttachmentsPostRequest();
                            req.entity = new Model.System.Attachement()
                            {
                                date = DateTime.Now, classId = ClassId.EPBC, recordId = Convert.ToInt32(b.recordId), fileName = bcFile.PostedFile.FileName, seqNo = 0
                            };
                            req.FileNames.Add(Regex.Replace(bcFile.PostedFile.FileName, @"[^0-9a-zA-Z.]+", ""));
                            req.FilesData.Add(fileData);
                            PostResponse <Attachement> resp = _systemService.UploadMultipleAttachments(req);
                            if (!resp.Success)//it maybe be another condition
                            {
                                //Show an error saving...
                                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                                Common.errorMessage(r);
                                return;
                            }
                        }
                        EmployeeBackgroundCheck BC = GetBCById(b.recordId);
                        ModelProxy record          = this.BCStore.GetById(id);
                        record.Set("expiryDate", BC.expiryDate);

                        record.Set("fileUrl", BC.fileUrl);

                        record.Set("ctId", BC.ctId);
                        record.Set("ctName", BC.ctName);
                        record.Set("remarks", BC.remarks);

                        record.Commit();

                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditBCWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
            //if (b.Date.Date == DateTime.Today)
            //{
            //    X.Call("parent.FillLeftPanel", b.departmentName + "<br/>", b.branchName + "<br/>", b.positionName + "<br/>");
            //    X.Call("parent.SelectJICombos", b.departmentId, b.branchId, b.positionId, b.divisionId);
            //}
        }
Пример #15
0
        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 id = e.ExtraParams["id"];

            string           obj         = e.ExtraParams["schedule"];
            PayrollIndemnity b           = JsonConvert.DeserializeObject <PayrollIndemnity>(obj);
            string           pers        = e.ExtraParams["periods"];
            string           indemnities = e.ExtraParams["indemnities"];

            b.recordId = id;
            // Define the object to add or edit as null
            List <PayrollIndemnityDetails>     periods         = JsonConvert.DeserializeObject <List <PayrollIndemnityDetails> >(pers);
            List <PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject <List <PayrollIndemnityRecognition> >(indemnities);

            if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0)
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show();
                return;
            }
            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <PayrollIndemnity> request = new PostRequest <PayrollIndemnity>();
                    request.entity = b;
                    PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(request);
                    b.recordId = r.recordId;



                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }

                    PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods);
                    //  AddPeriodsList1(b.recordId, periods);


                    if (!result.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }


                    PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList);
                    //  AddPeriodsList1(b.recordId, periods);

                    if (!result1.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }

                    else
                    {
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <PayrollIndemnity> modifyHeaderRequest = new PostRequest <PayrollIndemnity>();
                    modifyHeaderRequest.entity = b;

                    PostResponse <PayrollIndemnity> r = _payrollService.ChildAddOrUpdate <PayrollIndemnity>(modifyHeaderRequest);

                    //Step 1 Selecting the object or building up the object for update purpose
                    if (!r.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                        return;
                    }
                    //List<PayrollIndemnityDetails> periods = JsonConvert.DeserializeObject<List<PayrollIndemnityDetails>>(pers);
                    //List<PayrollIndemnityRecognition> indemnitiesList = JsonConvert.DeserializeObject<List<PayrollIndemnityRecognition>>(indemnities);
                    //if (periods == null || periods.Count == 0 || indemnitiesList == null || indemnitiesList.Count == 0)
                    //{
                    //    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    //    X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", "Error_Empty_IndemnityDetails_IndemnityResignation")).Show();
                    //    return;

                    //}

                    //_payrollService.DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId));
                    DeleteVacationSchedulePeriods(Convert.ToInt32(b.recordId));
                    //if (!deleteDesponse.Success)//it maybe another check
                    // {
                    //     X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    //      X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode) != null ? GetGlobalResourceObject("Errors", deleteDesponse.ErrorCode).ToString() : deleteDesponse.Summary).Show();
                    //     return;
                    // }

                    PostResponse <PayrollIndemnityDetails[]> result = AddPeriodsList(b.recordId, periods);

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (!result.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }


                    PostResponse <PayrollIndemnityRecognition[]> result1 = AddindemnitiesList(b.recordId, indemnitiesList);
                    //  AddPeriodsList1(b.recordId, periods);

                    if (!result1.Success)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : GetGlobalResourceObject("Errors", result.ErrorCode) != null ? GetGlobalResourceObject("Errors", result.ErrorCode).ToString() : result.Summary).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(index);
                        BasicInfoTab.UpdateRecord(record);

                        record.Commit();
                        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();
                }
            }
            Store1.Reload();
        }
Пример #16
0
        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"];
            LeavePayment b   = JsonConvert.DeserializeObject <LeavePayment>(obj);

            string id = e.ExtraParams["id"];

            // Define the object to add or edit as null

            //  b.employeeName = new EmployeeName();
            //if (ldMethodCom.SelectedItem != null)
            //    b.ldMethod = ldMethodCom.SelectedItem.Value;
            if (employeeId.SelectedItem != null)
            {
                b.employeeName = employeeId.SelectedItem.Text;
            }

            if (date.ReadOnly)
            {
                b.date = DateTime.Now;
            }
            //b.effectiveDate = new DateTime(b.effectiveDate.Year, b.effectiveDate.Month, b.effectiveDate.Day, 14, 0, 0);


            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <LeavePayment> request = new PostRequest <LeavePayment>();
                    request.entity = b;
                    PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(request);
                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }

                    else
                    {
                        b.recordId = r.recordId;

                        //Add this record to the store
                        //this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });
                        recordId.Text = b.recordId;

                        currentCase.Text = b.recordId;

                        //RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        //sm.DeselectAll();
                        //sm.Select(b.recordId.ToString());
                        Store1.Reload();
                        this.EditRecordWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <LeavePayment> request = new PostRequest <LeavePayment>();
                    request.entity = b;
                    PostResponse <LeavePayment> r = _payrollService.ChildAddOrUpdate <LeavePayment>(request);                      //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
                    {
                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);

                        if (date.ReadOnly)
                        {
                            record.Set("date", null);
                        }

                        record.Set("employeeName", b.employeeName);



                        record.Commit();
                        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();
                }
            }
        }
Пример #17
0
        protected void SaveNewRecord(object sender, DirectEventArgs e)
        {
            try
            {
                //Getting the id to check if it is an Add or an edit as they are managed within the same form.
                string id           = e.ExtraParams["id"];
                string disposedDate = e.ExtraParams["disposedDate"];

                string obj             = e.ExtraParams["values"];
                AssetManagementAsset b = JsonConvert.DeserializeObject <AssetManagementAsset>(obj);
                if (!string.IsNullOrEmpty(disposedDate))
                {
                    b.depreciationDate = DateTime.Parse(disposedDate);
                }
                b.recordId   = id;
                b.supplierId = supplierId.GetSupplierId() == "0"?null: supplierId.GetSupplierId();


                // Define the object to add or edit as null

                if (string.IsNullOrEmpty(id))
                {
                    try
                    {
                        //New Mode
                        //Step 1 : Fill The object and insert in the store
                        PostRequest <AssetManagementAsset> request = new PostRequest <AssetManagementAsset>();
                        request.entity = b;
                        PostResponse <AssetManagementAsset> r = _assetManagementService.ChildAddOrUpdate <AssetManagementAsset>(request);
                        b.recordId = r.recordId;

                        //check if the insert failed
                        if (!r.Success)//it maybe be another condition
                        {
                            //Show an error saving...

                            Common.errorMessage(r);
                            return;
                        }
                        else
                        {
                            //Add this record to the store


                            //Display successful notification
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordSavingSucc
                            });


                            Store1.Reload();
                            Panel8.Disabled   = false;
                            currentAsset.Text = r.recordId;
                            X.Call("setUrlAfterNewAsset");
                        }
                    }
                    catch (Exception ex)
                    {
                        //Error exception displaying a messsage box
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                    }
                }
                else
                {
                    //Update Mode

                    try
                    {
                        int index = Convert.ToInt32(id);//getting the id of the record
                        PostRequest <AssetManagementAsset> request = new PostRequest <AssetManagementAsset>();
                        request.entity = b;
                        PostResponse <AssetManagementAsset> r = _assetManagementService.ChildAddOrUpdate <AssetManagementAsset>(request);                      //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;
                            X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                            return;
                        }
                        else
                        {
                            ModelProxy record = this.Store1.GetById(index);
                            BasicInfoTab.UpdateRecord(record);
                            record.Commit();
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordUpdatedSucc
                            });
                            this.EditRecordWindow.Close();
                            Store1.Reload();
                        }
                    }
                    catch (Exception ex)
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                    }
                }
            }
            catch (Exception exp)
            {
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
            }
        }
Пример #18
0
        protected void SaveDocument(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 id = e.ExtraParams["id"];

            string obj            = e.ExtraParams["values"];
            EmployeeCertificate b = JsonConvert.DeserializeObject <EmployeeCertificate>(obj);

            b.employeeId = Convert.ToInt32(CurrentEmployee.Text);
            b.recordId   = id;
            // Define the object to add or edit as null
            b.clName = clId.SelectedItem.Text;
            if (b.dateFrom != null)
            {
                DateTime Date = (DateTime)b.dateFrom;
                b.dateFrom = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0);
            }
            if (b.dateTo != null)
            {
                DateTime Date = (DateTime)b.dateTo;
                b.dateTo = new DateTime(Date.Year, Date.Month, Date.Day, 14, 0, 0);
            }

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>();
                    request.entity = b;

                    PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request);
                    b.recordId = r.recordId;


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        this.skillStore.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditSkillWindow.Close();
                        RowSelectionModel sm = this.skillsGrid.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    int index = Convert.ToInt32(id);//getting the id of the record
                    PostRequest <EmployeeCertificate> request = new PostRequest <EmployeeCertificate>();
                    request.entity = b;



                    PostResponse <EmployeeCertificate> r = _employeeService.ChildAddOrUpdate <EmployeeCertificate>(request);


                    //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
                    {
                        ModelProxy record = this.skillStore.GetById(index);

                        SkillsForm.UpdateRecord(record);
                        record.Set("clName", b.clName);

                        record.Commit();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditSkillWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }
Пример #19
0
        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"];
            CertificateLevel b   = JsonConvert.DeserializeObject <CertificateLevel>(obj);

            string id = e.ExtraParams["id"];

            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(id))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <CertificateLevel> request = new PostRequest <CertificateLevel>();

                    request.entity = b;
                    PostResponse <CertificateLevel> r = _employeeService.ChildAddOrUpdate <CertificateLevel>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                    else
                    {
                        b.recordId = r.recordId;
                        //Add this record to the store
                        this.Store1.Insert(0, b);

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditRecordWindow.Close();
                        RowSelectionModel sm = this.GridPanel1.GetSelectionModel() as RowSelectionModel;
                        sm.DeselectAll();
                        sm.Select(b.recordId.ToString());
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    //getting the id of the record
                    PostRequest <CertificateLevel> request = new PostRequest <CertificateLevel>();
                    request.entity = b;
                    PostResponse <CertificateLevel> r = _employeeService.ChildAddOrUpdate <CertificateLevel>(request);                      //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;
                        X.Msg.Alert(Resources.Common.Error, r.Summary).Show();
                        return;
                    }
                    else
                    {
                        ModelProxy record = this.Store1.GetById(id);
                        BasicInfoTab.UpdateRecord(record);
                        record.Commit();
                        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();
                }
            }
        }
Пример #20
0
        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 id = e.ExtraParams["id"];

            string          obj  = e.ExtraParams["values"];
            string          addr = e.ExtraParams["address"];
            BusinessPartner b    = JsonConvert.DeserializeObject <BusinessPartner>(obj);


            b.recordId = id;
            // Define the object to add or edit as null



            // Define the object to add or edit as null
            CustomResolver res = new CustomResolver();

            res.AddRule("naId", "countryId");
            res.AddRule("stId", "stateId");
            JsonSerializerSettings settings = new JsonSerializerSettings();

            settings.ContractResolver = res;

            AddressBook add = JsonConvert.DeserializeObject <AddressBook>(addr, settings);

            if (string.IsNullOrEmpty(add.city) && string.IsNullOrEmpty(add.countryId) && string.IsNullOrEmpty(add.street1) && string.IsNullOrEmpty(add.stateId) && string.IsNullOrEmpty(add.phone))
            {
                b.address = null;
            }
            else
            {
                if (string.IsNullOrEmpty(add.city) || string.IsNullOrEmpty(add.countryId) || string.IsNullOrEmpty(add.street1) || string.IsNullOrEmpty(add.stateId) || string.IsNullOrEmpty(add.phone))
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, GetLocalResourceObject("ErrorAddressMissing")).Show();
                    return;
                }
                b.address          = JsonConvert.DeserializeObject <AddressBook>(addr, settings);
                b.address.recordId = address.Text;


                if (string.IsNullOrEmpty(id))
                {
                    try
                    {
                        //New Mode
                        //Step 1 : Fill The object and insert in the store
                        PostRequest <BusinessPartner> request = new PostRequest <BusinessPartner>();
                        request.entity = b;
                        PostResponse <BusinessPartner> r = _administrationService.ChildAddOrUpdate <BusinessPartner>(request);
                        b.recordId = r.recordId;

                        //check if the insert failed
                        if (!r.Success)//it maybe be another condition
                        {
                            //Show an error saving...
                            X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                            Common.errorMessage(r);;
                            return;
                        }
                        else
                        {
                            Notification.Show(new NotificationConfig
                            {
                                Title = Resources.Common.Notification,
                                Icon  = Icon.Information,
                                Html  = Resources.Common.RecordSavingSucc
                            });
                            //Add this record to the store


                            //Display successful notification

                            Store1.Reload();
                            EditRecordWindow.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        //Error exception displaying a messsage box
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                    }
                }
                else
                {
                    //Update Mode

                    try
                    {
                        PostRequest <BusinessPartner> request = new PostRequest <BusinessPartner>();

                        request.entity = b;
                        PostResponse <BusinessPartner> r = _administrationService.ChildAddOrUpdate <BusinessPartner>(request);                      //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
                        {
                            ModelProxy record = this.Store1.GetById(id);

                            BasicInfoTab.UpdateRecord(record);

                            record.Commit();
                            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();
                    }
                }
            }
        }