Example #1
0
        protected void addPosition(object sender, DirectEventArgs e)
        {
            if (string.IsNullOrEmpty(referToPositionId.Text))
            {
                return;
            }
            Model.Company.Structure.Position dept = new Model.Company.Structure.Position();
            dept.name = referToPositionId.Text;

            PostRequest <Model.Company.Structure.Position> depReq = new PostRequest <Model.Company.Structure.Position>();

            depReq.entity = dept;
            PostResponse <Model.Company.Structure.Position> response = _branchService.ChildAddOrUpdate <Model.Company.Structure.Position>(depReq);

            if (response.Success)
            {
                dept.recordId = response.recordId;
                positionStore.Reload();
                referToPositionId.Select(dept.recordId);
                Store1.Insert(0, dept);
            }
            else
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(response);
                return;
            }
        }
Example #2
0
        public void DeleteRecord(string index)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                PostRequest <Model.Company.Structure.Position> req = new PostRequest <Model.Company.Structure.Position>();
                Model.Company.Structure.Position p = new Model.Company.Structure.Position();
                p.recordId = index;
                req.entity = p;
                PostResponse <Model.Company.Structure.Position> resp = _branchService.ChildDelete <Model.Company.Structure.Position>(req);
                if (!resp.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(resp);
                    return;
                }
                //Step 2 :  remove the object from the store
                Store1.Remove(index);

                //Step 3 : Showing a notification for the user
                Notification.Show(new NotificationConfig
                {
                    Title = Resources.Common.Notification,
                    Icon  = Icon.Information,
                    Html  = Resources.Common.RecordDeletedSucc
                });
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
Example #3
0
        private void InitCombos(Model.Company.Structure.Position dept)
        {
            //parents = new BoundedComboBox("referToPositionId", "name", "recordId", GetLocalResourceObject("FieldReferer").ToString(), "FillParent", "", GetLocalResourceObject("FieldReferer").ToString(), false);

            //BasicInfoTab.Items.Add(parents);

            //if (dept != null)
            //{

            //    parents.Select(dept.referToPositionId);

            //}
            referToPositionId.Select(dept.referToPositionId);
        }
Example #4
0
        protected void addPosition(object sender, DirectEventArgs e)
        {
            Model.Company.Structure.Position dept = new Model.Company.Structure.Position();
            dept.name = positionId.Text;

            PostRequest <Model.Company.Structure.Position> depReq = new PostRequest <Model.Company.Structure.Position>();

            depReq.entity = dept;
            PostResponse <Model.Company.Structure.Position> response = _companyStructureService.ChildAddOrUpdate <Model.Company.Structure.Position>(depReq);

            if (response.Success)
            {
                dept.recordId = response.recordId;
                FillPosition();
                positionId.Select(dept.recordId);
            }
            else
            {
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                Common.errorMessage(response);
                return;
            }
        }
Example #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 id = e.ExtraParams["id"];

            string obj = e.ExtraParams["values"];

            Model.Company.Structure.Position b = JsonConvert.DeserializeObject <Model.Company.Structure.Position>(obj);
            if (referToPositionId.SelectedItem != null)
            {
                b.referToPositionName = referToPositionId.SelectedItem.Text;
            }
            //if (tsId.SelectedItem != null)
            //    b.tsName = tsId.SelectedItem.Text;
            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 <Model.Company.Structure.Position> request = new PostRequest <Model.Company.Structure.Position>();
                    request.entity = b;
                    PostResponse <Model.Company.Structure.Position> r = _branchService.ChildAddOrUpdate <Model.Company.Structure.Position>(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
                        });

                        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 <Model.Company.Structure.Position> request = new PostRequest <Model.Company.Structure.Position>();
                    request.entity = b;
                    PostResponse <Model.Company.Structure.Position> r = _branchService.ChildAddOrUpdate <Model.Company.Structure.Position>(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.Set("referToPositionName", b.referToPositionName);
                        record.Set("tsName", b.tsName);
                        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();
                }
            }
        }