コード例 #1
0
        private void Leavelist_ItemTapped(object sender, ItemTappedEventArgs e)
        {
            if (CrossConnectivity.Current.IsConnected)
            {
                try
                {
                    LeavesModel data = (LeavesModel)e.Item;
                    Navigation.PushAsync(new LeavesDetailPage(data));
                }

                catch
                {
                    LeavesModelDB data = (LeavesModelDB)e.Item;
                    Navigation.PushAsync(new LeavesDetailPage(data));
                }
            }
            else
            {
                try
                {
                    LeavesModelDB data = (LeavesModelDB)e.Item;
                    Navigation.PushAsync(new LeavesDetailPage(data));
                }
                catch
                {
                    LeavesModel data = (LeavesModel)e.Item;
                    Navigation.PushAsync(new LeavesDetailPage(data));
                }
            }
        }
コード例 #2
0
        public List <LeavesModel> GetMasterData()
        {
            try
            {
                JObject res = odooConnector.odooFilterDataCall("res.users", "get_master_data");

                App.user_name   = res["user_name"].ToString();
                App.user_image  = res["user_image_medium"].ToString();
                App.user_mobile = res["user_mobile"].ToString();
                App.user_email  = res["user_email"].ToString();
                App.partner_id  = res["partner_id"].ToObject <int>();
                App.employee_id = res["employee_id"].ToObject <int>();

                App.productList         = res["Products"].ToObject <List <ProductsList> >();
                App.expense_productList = res["expense_products"].ToObject <List <ExpenseProductsList> >();

                App.product_Uom   = res["product_uom"].ToObject <List <ProductUOM> >();
                App.taxList       = res["taxes"].ToObject <List <taxes> >();
                App.hr_yearList   = res["hr_years"].ToObject <List <HRYear> >();
                App.currencyList  = res["available_currency"].ToObject <List <Currency> >();
                App.leaveTypeList = res["holiday_status"].ToObject <List <LeaveType> >();

                App.employee_list = res["employees"].ToObject <List <EmployeesModel> >();

                App.access_dict = res["access_right"].ToObject <Dictionary <string, dynamic> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <UserModelDB>();

                if (App.UserListDb.Count == 0)
                {
                    var jso_tags_list            = Newtonsoft.Json.JsonConvert.SerializeObject(res["taxes"]);
                    var jso_products_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["Products"]);
                    var jso_expenseproducts_list = Newtonsoft.Json.JsonConvert.SerializeObject(res["expense_products"]);
                    var jso_product_Uomlist      = Newtonsoft.Json.JsonConvert.SerializeObject(res["product_uom"]);
                    var jso_hr_year_list         = Newtonsoft.Json.JsonConvert.SerializeObject(res["hr_years"]);
                    var jso_currency_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["available_currency"]);
                    var jso_leavetype_list       = Newtonsoft.Json.JsonConvert.SerializeObject(res["holiday_status"]);
                    var jso_employee_list        = Newtonsoft.Json.JsonConvert.SerializeObject(res["employees"]);

                    var sample = new UserModelDB
                    {
                        userid            = App.userid,
                        partnerid         = App.partner_id,
                        employeeid        = App.employee_id,
                        user_name         = App.user_name,
                        user_email        = App.user_email,
                        user_mobile       = App.user_mobile,
                        user_image_medium = App.user_image,
                        products          = jso_products_list,
                        expense_products  = jso_expenseproducts_list,
                        tax_list          = jso_tags_list,
                        product_Uom       = jso_product_Uomlist,
                        hr_year_list      = jso_hr_year_list,
                        currency_list     = jso_currency_list,
                        leavetype_list    = jso_leavetype_list,
                        employee_list     = jso_employee_list,
                    };
                    App._connection.Insert(sample);

                    try
                    {
                        var details = (from y in App._connection.Table <UserModelDB>() select y).ToList();
                        App.UserListDb = details;

                        List <ProductsList>        productslistdb         = new List <ProductsList>();
                        List <ExpenseProductsList> expense_productslistdb = new List <ExpenseProductsList>();
                        List <taxes>          taxListDb       = new List <taxes>();
                        List <ProductUOM>     product_UomDb   = new List <ProductUOM>();
                        List <Currency>       currencyListDb  = new List <Currency>();
                        List <HRYear>         hr_yearListDb   = new List <HRYear>();
                        List <LeaveType>      leaveTypeListDb = new List <LeaveType>();
                        List <EmployeesModel> employeeListDb  = new List <EmployeesModel>();

                        foreach (var item in App.UserListDb)
                        {
                            productslistdb         = JsonConvert.DeserializeObject <List <ProductsList> >(item.products);
                            expense_productslistdb = JsonConvert.DeserializeObject <List <ExpenseProductsList> >(item.expense_products);
                            taxListDb                 = JsonConvert.DeserializeObject <List <taxes> >(item.tax_list);
                            product_UomDb             = JsonConvert.DeserializeObject <List <ProductUOM> >(item.product_Uom);
                            currencyListDb            = JsonConvert.DeserializeObject <List <Currency> >(item.currency_list);
                            hr_yearListDb             = JsonConvert.DeserializeObject <List <HRYear> >(item.hr_year_list);
                            leaveTypeListDb           = JsonConvert.DeserializeObject <List <LeaveType> >(item.leavetype_list);
                            employeeListDb            = JsonConvert.DeserializeObject <List <EmployeesModel> >(item.employee_list);
                            App.userid_db             = item.userid;
                            App.ProductListDb         = productslistdb;
                            App.expense_productListDb = expense_productslistdb;
                            App.taxListDb             = taxListDb;
                            App.product_UomDb         = product_UomDb;
                            App.hr_yearListDb         = hr_yearListDb;
                            App.currencyListDb        = currencyListDb;
                            App.leaveTypeListDb       = leaveTypeListDb;
                            App.employee_idDb         = item.employeeid;
                            App.employee_listDb       = employeeListDb;
                        }
                    }
                    catch (Exception ex)
                    {
                        int i = 0;
                    }
                }

                /////// For Leaves

                App.leaves_list = res["holidays"].ToObject <List <LeavesModel> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <LeavesModelDB>();

                //  List<AttachmentFile> attlistDb = new List<AttachmentFile>();



                var leaves_details = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where sync_string = ?", "sync.png");
                if (leaves_details.Count() == 0)
                {
                    App._connection.Query <LeavesModelDB>("DELETE from LeavesModelDB");

                    foreach (var item in App.leaves_list)
                    {
                        var dbattachment_list = Newtonsoft.Json.JsonConvert.SerializeObject(item.attachment);

                        var sample = new LeavesModelDB
                        {
                            id              = item.id,
                            name            = item.name,
                            display_name    = item.display_name,
                            state           = item.state,
                            state_name      = item.state_name,
                            date_from       = item.date_from,
                            date_to         = item.date_to,
                            no_of_days      = item.no_of_days,
                            stage_colour    = item.stage_colour,
                            is_half_day     = item.is_half_day,
                            am_or_pm        = item.am_or_pm,
                            leave_structure = item.leave_structure,
                            year            = item.year,
                            employee        = item.employee,
                            report_note     = item.report_note,
                            holidays_status = item.holidays_status,
                            datefrom        = item.datefrom,
                            dateto          = item.dateto,
                            fromDate        = item.fromDate,
                            endDate         = item.endDate,
                            check_tt        = item.check_tt,
                            department      = item.department,
                            attachment_list = dbattachment_list,
                            date            = item.date,
                        };
                        App._connection.Insert(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();
                        App.leaves_listDb = details;
                    }
                    catch
                    {
                        int i = 0;
                    }
                }

                var rpc_condition = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where check_rpc_condition = ?", "false");
                if (rpc_condition.Count != 0)
                {
                    //  List<AttachmentFile> productslistdb = new List<AttachmentFile>();

                    foreach (var item in rpc_condition)
                    {
                        var sample = new LeavesModel
                        {
                            name                = item.name,
                            holidays_status     = item.holidays_status,
                            year                = item.year,
                            date_from           = item.date_from,
                            date_to             = item.date_to,
                            state               = item.state,
                            state_name          = item.state_name,
                            stage_colour        = item.stage_colour,
                            no_of_days          = item.no_of_days,
                            is_half_day         = item.is_half_day,
                            sync_string         = item.sync_string,
                            am_or_pm            = item.check_tt,
                            employee            = item.employee,
                            error_rpcTxt        = item.txt_rpc_error,
                            dbid_error_txt      = item.Dbid,
                            check_rpc_condition = item.check_rpc_condition,
                            //  attachlistfield = item.error_attachment_list,

                            attachment = JsonConvert.DeserializeObject <List <AttachmentFile> >(item.attachment_list),
                            // attachment = item.error_attachment_list,
                        };
                        App.leaves_list.Add(sample);
                    }
                }
                var data = App.leaves_list;

                /////// For Expense
                App.expense_list = res["expense"].ToObject <List <ExpenseModel> >();

                App._connection = DependencyService.Get <ISQLiteDb>().GetConnection();
                App._connection.CreateTable <ExpenseModelDB>();

                var expense_details = App._connection.Query <ExpenseModelDB>("SELECT * from ExpenseModelDB where sync_string = ? OR sync_string = ?", "sync.png", "editexp.png");
                if (expense_details.Count() == 0)
                {
                    App._connection.Query <ExpenseModelDB>("DELETE from ExpenseModelDB");

                    foreach (var item in App.expense_list)
                    {
                        var expattach_list = Newtonsoft.Json.JsonConvert.SerializeObject(item.attachment);

                        var sample = new ExpenseModelDB
                        {
                            id           = item.id,
                            name         = item.name,
                            product      = item.product,
                            product_uom  = item.product_uom,
                            state        = item.state,
                            unit_price   = item.unit_price,
                            quantity     = item.quantity,
                            reference    = item.reference,
                            notes        = item.notes,
                            account      = item.account,
                            employee_id  = item.employee_id,
                            currency     = item.currency,
                            date         = item.date,
                            stage_name   = item.stage_name,
                            stage_colour = item.stage_colour,
                            half_date    = item.half_date,
                            full_date    = item.full_date,

                            attachment = expattach_list,
                        };
                        App._connection.Insert(sample);
                    }

                    try
                    {
                        var details = (from y in App._connection.Table <ExpenseModelDB>() select y).ToList();
                        App.expense_listDb = details;
                    }
                    catch
                    {
                        int i = 0;
                    }
                }

                return(App.leaves_list);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("::::: HRM Warning Message ::::  " + ex.Message);

                if (ex.Message.Contains("(Network is unreachable)") || ex.Message.Contains("NameResolutionFailure"))
                {
                    App.NetAvailable = false;
                }
                else if (ex.Message.Contains("(503) Service Unavailable"))
                {
                    App.responseState = false;
                }
                return(App.leaves_list);
            }
        }
コード例 #3
0
        //bool updated = Controller.InstanceCreation().submittomanager("hr.expense", "app_approve_expense_sheets", expobj.id);

        public LeavesDetailPage(LeavesModel obj)
        {
            InitializeComponent();

            attach.Clear();

            start_date.Format = "dd/MM/yyyy";
            stop_date.Format  = "dd/MM/yyyy";

            levobj = obj;

            leave_officer = App.access_dict.FirstOrDefault(x => x.Key == "holiday_officer").Value;

            leave_manager = App.access_dict.FirstOrDefault(x => x.Key == "holiday_manager").Value;

            //if (!leave_officer || !leave_manager)
            //{
            //    btnApprove.IsVisible = false;
            //    btnConfirm.IsVisible = false;
            //    btnRefuse.IsVisible = false;

            //}


            reasonlabel.Text    = obj.name;
            leavetypelabel.Text = obj.holidays_status;
            hryearlabel.Text    = obj.year;

            if (obj.check_rpc_condition != "false")
            {
                label_display_Name.Text = obj.display_name;
            }
            else
            {
                delete.IsVisible                   = true;
                label_display_Name.Text            = obj.error_rpcTxt;
                label_display_Name.TextColor       = Color.Red;
                durlayout.IsVisible                = false;
                dur_boxlayout.IsVisible            = false;
                state_layout.IsVisible             = false;
                state_boxlayout.IsVisible          = false;
                leavestructure_layout.IsVisible    = false;
                leavestructure_boxlayout.IsVisible = false;
                department_layout.IsVisible        = false;
                department_boxlayout.IsVisible     = false;
                btnStack.IsVisible                 = false;

                //  attach = JsonConvert.DeserializeObject<List<AttachmentFile>>(obj.attachment);
                attach = obj.attachment;
                if (attach.Count > 0)
                {
                    attachviewlist.IsVisible     = true;
                    attachviewlist.HeightRequest = 45 * attach.Count;
                    attachviewlist.ItemsSource   = attach;
                }
            }

            attach = obj.attachment;
            if (attach.Count > 0)
            {
                attachviewlist.IsVisible     = true;
                attachviewlist.HeightRequest = 45 * attach.Count;
                attachviewlist.ItemsSource   = attach;
            }

            leave_pick.ItemsSource     = App.leaveTypeList.Select(n => n.Name2).ToList();
            hr_year_picker.ItemsSource = App.hr_yearList.Select(y => y.Name).ToList();

            //employee_namelabel.Text = obj.employee;
            leave_structure_Namelabel.Text = obj.leave_structure;
            dept_namelabel.Text            = obj.department;

            startdate_label.Text = obj.fromDate;
            enddate_label.Text   = obj.endDate;
            duration_label.Text  = obj.no_of_days.ToString();

            if (obj.is_half_day == false)
            {
                checkImg.IsVisible               = false;
                uncheckImg.IsVisible             = true;
                tt_label.Text                    = obj.check_tt;
                check_half_day                   = false;
                overall_enddate_layout.IsVisible = true;
            }
            else
            {
                checkImg.IsVisible               = true;
                uncheckImg.IsVisible             = false;
                tt_label.Text                    = obj.check_tt;
                check_half_day                   = true;
                overall_enddate_layout.IsVisible = false;
            }

            if (obj.state.Equals("confirm"))
            {
                btnApprove.IsVisible = true;
                btnRefuse.IsVisible  = true;
                btnDraft.IsVisible   = true;
                btnConfirm.IsVisible = false;
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.state_name;
            }
            else if (obj.state.Equals("draft"))
            {
                btnConfirm.IsVisible = true;
                btnApprove.IsVisible = false;
                btnRefuse.IsVisible  = false;
                btnDraft.IsVisible   = false;
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.state_name;
            }
            else if (obj.state.Equals("refuse"))
            {
                btnConfirm.IsVisible = false;
                btnApprove.IsVisible = false;
                btnRefuse.IsVisible  = false;
                btnDraft.IsVisible   = true;
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.state_name;
            }
            else if (obj.state.Equals("validate"))
            {
                btnConfirm.IsVisible = false;
                btnApprove.IsVisible = false;
                btnRefuse.IsVisible  = true;
                btnDraft.IsVisible   = false;
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.state_name;
            }


            if (!leave_officer || !leave_manager)
            {
                if (obj.state.Equals("confirm"))
                {
                    btnApprove.IsVisible = false;
                    btnRefuse.IsVisible  = false;
                    btnDraft.IsVisible   = true;
                    btnConfirm.IsVisible = false;
                    frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                    statelabel.Text = obj.state_name;
                }
                else if (obj.state.Equals("draft"))
                {
                    btnConfirm.IsVisible = true;
                    btnApprove.IsVisible = false;
                    btnRefuse.IsVisible  = false;
                    btnDraft.IsVisible   = false;
                    frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                    statelabel.Text = obj.state_name;
                }
            }


            halfday.Add("AM");
            halfday.Add("PM");
            half_dayPicker.ItemsSource   = halfday;
            half_dayPicker.SelectedIndex = 0;


            var deleteRecognizer = new TapGestureRecognizer();

            deleteRecognizer.Tapped += async(s, e) =>
            {
                string title = "Alert";
                string txt   = "Are you sure you want to delete this record?";
                await PopupNavigation.Instance.PushAsync(new CustomAlert(txt, title));
            };
            delete.GestureRecognizers.Add(deleteRecognizer);

            var editRecognizer = new TapGestureRecognizer();

            editRecognizer.Tapped += (s, e) =>
            {
                edit.IsVisible           = false;
                add_attachment.IsEnabled = true;
                attachviewlist.IsEnabled = true;
                if (obj.check_rpc_condition != "false")
                {
                    updatebtn.IsVisible = true;
                }
                else
                {
                    createbtn.IsVisible                = true;
                    durlayout.IsVisible                = false;
                    dur_boxlayout.IsVisible            = false;
                    delete.IsVisible                   = false;
                    state_layout.IsVisible             = false;
                    state_boxlayout.IsVisible          = false;
                    leavestructure_layout.IsVisible    = false;
                    leavestructure_boxlayout.IsVisible = false;
                    department_layout.IsVisible        = false;
                    department_boxlayout.IsVisible     = false;
                    btnStack.IsVisible                 = false;
                }

                leave_pick.ItemsSource   = App.leaveTypeList.Select(n => n.Name2).ToList();
                leave_pick.SelectedIndex = 0;
                leave_pick.SelectedItem  = obj.holidays_status;

                hr_year_picker.ItemsSource   = App.hr_yearList.Select(y => y.Name).ToList();
                hr_year_picker.SelectedIndex = 0;
                hr_year_picker.SelectedItem  = obj.year;

                reasonlabel.IsVisible  = false;
                reason_entry.IsVisible = true;
                reason_entry.Text      = obj.name;

                leavetypelabel.IsVisible   = false;
                leavetype_layout.IsVisible = true;

                //employee_namelabel.IsVisible = false;
                //employee_layout.IsVisible = true;

                hryearlabel.IsVisible   = false;
                hryear_layout.IsVisible = true;

                startdate_label.IsVisible  = false;
                startdate_layout.IsVisible = true;

                enddate_label.IsVisible  = false;
                enddate_layout.IsVisible = true;

                // half day field
                uncheckImg.IsVisible = false;
                checkImg.IsVisible   = false;
                tt_label.IsVisible   = false;
                if (obj.is_half_day == false)
                {
                    editcheckImg.IsVisible           = false;
                    edituncheckImg.IsVisible         = true;
                    half_dayPicker.IsVisible         = false;
                    drdownImg.IsVisible              = false;
                    overall_enddate_layout.IsVisible = true;
                }
                else
                {
                    editcheckImg.IsVisible           = true;
                    edituncheckImg.IsVisible         = false;
                    half_dayPicker.IsVisible         = true;
                    half_dayPicker.SelectedItem      = obj.check_tt;
                    drdownImg.IsVisible              = true;
                    overall_enddate_layout.IsVisible = false;
                }
                halfday_layout.IsVisible = true;

                //start date field
                DateTime start_dateTime   = DateTime.ParseExact(obj.date_from, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture).ToLocalTime();
                string   start_datestring = start_dateTime.ToString("yyyy-MM-dd");
                string   start_timestring = start_dateTime.ToString("HH:mm");
                string   start_fullTime   = start_datestring + " " + start_timestring;
                TimeSpan start_timespan   = TimeSpan.Parse(start_timestring);
                start_date.Date = start_dateTime;
                start_time.Time = start_timespan;

                //stop date field
                DateTime stop_dateTime   = DateTime.ParseExact(obj.date_to, "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture).ToLocalTime();
                string   stop_datestring = stop_dateTime.ToString("yyyy-MM-dd");
                string   stop_timestring = stop_dateTime.ToString("HH:mm");
                string   stop_fullTime   = stop_datestring + " " + stop_timestring;
                TimeSpan stop_timespan   = TimeSpan.Parse(stop_timestring);
                stop_date.Date = stop_dateTime;
                stop_time.Time = stop_timespan;
            };
            edit.GestureRecognizers.Add(editRecognizer);

            //// check box
            var uncheck_Img = new TapGestureRecognizer();

            uncheck_Img.Tapped += (s, e) =>
            {
                edituncheckImg.IsVisible         = false;
                editcheckImg.IsVisible           = true;
                half_dayPicker.IsVisible         = true;
                drdownImg.IsVisible              = true;
                check_half_day                   = true;
                overall_enddate_layout.IsVisible = false;
            };
            edituncheckImg.GestureRecognizers.Add(uncheck_Img);

            var check_Img = new TapGestureRecognizer();

            check_Img.Tapped += (s, e) =>
            {
                editcheckImg.IsVisible           = false;
                edituncheckImg.IsVisible         = true;
                half_dayPicker.IsVisible         = false;
                drdownImg.IsVisible              = false;
                check_half_day                   = false;
                overall_enddate_layout.IsVisible = true;
            };
            editcheckImg.GestureRecognizers.Add(check_Img);

            ///////Attachment
            var attach_file = new TapGestureRecognizer();

            attach_file.Tapped += async(s, e) =>
            {
                System.Diagnostics.Debug.WriteLine("OUTT" + attach.Count());


                await PopupNavigation.Instance.PushAsync(new FileAttachmentPage("update", attach));
            };
            add_attachment.GestureRecognizers.Add(attach_file);
        }
コード例 #4
0
        async Task MainRefreshData()
        {
            try
            {
                Device.StartTimer(new TimeSpan(0, 0, 1), () =>
                {
                    if (App.NetAvailable == false)
                    {
                        List <LeavesModel> Data = Controller.InstanceCreation().GetMasterData();
                    }
                    //var leaves_details = App._connection.Query<LeavesModelDB>("SELECT * from LeavesModelDB where sync_string = ?", "sync.png");
                    var leaves_details = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where check_rpc_condition = ?", "true");

                    var rpc_condition = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where check_rpc_condition = ?", "false");

                    if (leaves_details.Count() != 0 && App.NetAvailable == true)
                    {
                        foreach (var dbobj in leaves_details)
                        {
                            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();

                            vals["name"] = dbobj.name;
                            vals["holiday_status_id"]   = dbobj.leave_type_id;
                            vals["hr_year_id"]          = dbobj.year_id;
                            vals["employee_id"]         = dbobj.employee_id;
                            vals["date_from"]           = dbobj.date_from;
                            vals["date_to"]             = dbobj.date_to;
                            vals["half_day"]            = dbobj.is_half_day;
                            vals["half_day_related"]    = dbobj.is_half_day;
                            vals["am_or_pm"]            = dbobj.check_tt;
                            vals["number_of_days_temp"] = dbobj.no_of_days;

                            var json_attachment = JsonConvert.DeserializeObject(dbobj.attachment_list);

                            vals["attachment"] = json_attachment;

                            var created = "";

                            created = Controller.InstanceCreation().CreateLeave("hr.holidays", "app_create_leave", vals);
                            if (created == "True")
                            {
                                //App._connection.Query<LeavesModelDB>("UPDATE LeavesModelDB set sync_string=? Where Dbid=?", "", dbobj.Dbid);

                                App._connection.Query <LeavesModelDB>("DELETE FROM LeavesModelDB WHERE Dbid=?", dbobj.Dbid);

                                App._connection.CreateTable <LeavesModelDB>();
                                var details       = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();
                                App.leaves_listDb = details;

                                List <LeavesModel> Data = Controller.InstanceCreation().GetMasterData();
                                MessagingCenter.Send <string, String>("MyApp", "LeavesListUpdated", "true");
                            }
                            else
                            {
                                App._connection.Query <LeavesModelDB>("UPDATE LeavesModelDB set check_rpc_condition=? Where Dbid=?", "false", dbobj.Dbid);
                                App._connection.Query <LeavesModelDB>("UPDATE LeavesModelDB set txt_rpc_error=? Where Dbid=?", created, dbobj.Dbid);

                                App._connection.CreateTable <LeavesModelDB>();
                                var details = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();

                                App.leaves_listDb = details;

                                LeavesModel data         = new LeavesModel();
                                data.name                = dbobj.name;
                                data.holidays_status     = dbobj.holidays_status;
                                data.year                = dbobj.year;
                                data.date_from           = dbobj.date_from;
                                data.date_to             = dbobj.date_to;
                                data.state               = dbobj.state;
                                data.state_name          = dbobj.state_name;
                                data.stage_colour        = dbobj.stage_colour;
                                data.no_of_days          = dbobj.no_of_days;
                                data.is_half_day         = dbobj.is_half_day;
                                data.sync_string         = dbobj.sync_string; ///"sync.png";
                                data.am_or_pm            = dbobj.check_tt;
                                data.employee            = dbobj.employee;
                                data.error_rpcTxt        = created;
                                data.dbid_error_txt      = dbobj.Dbid;
                                data.check_rpc_condition = "false";

                                data.attachment = JsonConvert.DeserializeObject <List <AttachmentFile> >(dbobj.error_attachment_list);
                                // data.attachment = dbobj.error_attachment_list;
                                int i = 0;

                                App.leaves_list.Add(data);

                                var lea = App.leaves_list;

                                List <LeavesModel> Data = Controller.InstanceCreation().GetMasterData();
                                MessagingCenter.Send <string, String>("MyApp", "LeavesListUpdated", "true");
                            }
                        }
                    }


                    var leave_edits = App._connection.Query <LeavesModelDB>("SELECT * from LeavesModelDB where check_rpc_condition = ?", "edit");

                    if (leave_edits.Count() != 0 && CrossConnectivity.Current.IsConnected == true)
                    {
                        foreach (var dbobj in leave_edits)
                        {
                            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();
                            List <dynamic> attfile            = new List <dynamic>();

                            List <AttachmentFile> addattachlistDb = JsonConvert.DeserializeObject <List <AttachmentFile> >(dbobj.attachment_list);
                            List <int> removeListDb = JsonConvert.DeserializeObject <List <int> >(dbobj.remove_attachment);

                            foreach (var data in addattachlistDb)
                            {
                                if (data.id == 0)
                                {
                                    Dictionary <string, dynamic> dict = new Dictionary <string, dynamic>();

                                    dict.Add("file_name", data.file_name);
                                    // dict.Add("file_data", data.filebase64);
                                    dict.Add("file_data", data.file_data);
                                    attfile.Add(dict);
                                }
                            }

                            vals["name"] = dbobj.name;
                            vals["holiday_status_id"] = dbobj.leave_type_id;
                            vals["hr_year_id"]        = dbobj.year_id;
                            vals["employee_id"]       = dbobj.employee_id;

                            vals["date_from"]           = dbobj.date_from;
                            vals["date_to"]             = dbobj.date_to;
                            vals["number_of_days_temp"] = dbobj.no_of_days;
                            vals["half_day_related"]    = dbobj.is_half_day;
                            vals["half_day"]            = dbobj.is_half_day;
                            vals["am_or_pm"]            = dbobj.check_tt;
                            vals["add_attachment"]      = addattachlistDb;
                            vals["remove_attachment"]   = removeListDb;

                            //      var created = "";

                            var updated = Controller.InstanceCreation().UpdateLeave("hr.holidays", "app_update_leave", dbobj.id, vals);

                            if (updated == "True")
                            {
                                //App._connection.Query<LeavesModelDB>("UPDATE LeavesModelDB set sync_string=? Where Dbid=?", "", dbobj.Dbid);

                                App._connection.Query <LeavesModelDB>("DELETE FROM LeavesModelDB WHERE Dbid=?", dbobj.Dbid);

                                App._connection.CreateTable <LeavesModelDB>();
                                var details       = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();
                                App.leaves_listDb = details;

                                Task.Run(() => Controller.InstanceCreation().GetMasterData());
                                //  List<LeavesModel> Data = Controller.InstanceCreation().GetMasterData();
                                MessagingCenter.Send <string, String>("MyApp", "LeavesListUpdated", "true");
                            }
                            else
                            {
                                Task.Run(() => Controller.InstanceCreation().GetMasterData());
                                MessagingCenter.Send <string, String>("MyApp", "ErrorListUpdated", updated);

                                App._connection.Query <LeavesModelDB>("DELETE FROM LeavesModelDB WHERE Dbid=?", dbobj.Dbid);

                                App._connection.CreateTable <LeavesModelDB>();
                                var details       = (from y in App._connection.Table <LeavesModelDB>() select y).ToList();
                                App.leaves_listDb = details;
                            }
                        }
                    }


                    var expense_details = App._connection.Query <ExpenseModelDB>("SELECT * from ExpenseModelDB where check_rpc_condition = ?", "true");

                    if (expense_details.Count() != 0 && App.NetAvailable == true)
                    {
                        foreach (var dbobj in expense_details)
                        {
                            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();

                            vals["name"]           = dbobj.name;
                            vals["product_id"]     = dbobj.product_id;
                            vals["unit_amount"]    = dbobj.unit_price;
                            vals["quantity"]       = dbobj.quantity;
                            vals["product_uom_id"] = dbobj.uom_id;
                            vals["reference"]      = dbobj.reference;
                            vals["date"]           = dbobj.date;
                            vals["employee_id"]    = dbobj.emp_id;
                            vals["currency_id"]    = dbobj.currency_id;
                            vals["total_amount"]   = dbobj.total;

                            var json_attachment = JsonConvert.DeserializeObject(dbobj.attachment);
                            vals["attachment"]  = json_attachment;

                            var created = Controller.InstanceCreation().CreateLeave("hr.expense", "app_create_expense", vals);


                            if (created == "True")
                            {
                                //App._connection.Query<LeavesModelDB>("UPDATE LeavesModelDB set sync_string=? Where Dbid=?", "", dbobj.Dbid);

                                App._connection.Query <ExpenseModelDB>("DELETE FROM ExpenseModelDB WHERE Dbid=?", dbobj.Dbid);

                                App._connection.CreateTable <ExpenseModelDB>();
                                var details        = (from y in App._connection.Table <ExpenseModelDB>() select y).ToList();
                                App.expense_listDb = details;

                                List <LeavesModel> Data = Controller.InstanceCreation().GetMasterData();
                                MessagingCenter.Send <string, String>("MyApp", "ExpenseListUpdated", "true");
                            }
                        }
                    }


                    var expense_edits = App._connection.Query <ExpenseModelDB>("SELECT * from ExpenseModelDB where check_rpc_condition = ?", "edit");

                    if (expense_edits.Count() != 0 && App.NetAvailable == true)
                    {
                        foreach (var dbobj in expense_edits)
                        {
                            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();

                            vals["name"]           = dbobj.name;
                            vals["product_id"]     = dbobj.product_id;
                            vals["unit_amount"]    = dbobj.unit_price;
                            vals["quantity"]       = dbobj.quantity;
                            vals["product_uom_id"] = dbobj.uom_id;
                            vals["reference"]      = dbobj.reference;
                            vals["date"]           = dbobj.date;

                            List <AttachmentFile> addattachlistDb = JsonConvert.DeserializeObject <List <AttachmentFile> >(dbobj.attachment);
                            List <int> removeListDb = JsonConvert.DeserializeObject <List <int> >(dbobj.remove_attachment);

                            vals["add_attachment"]    = addattachlistDb;
                            vals["remove_attachment"] = removeListDb;
                            vals["employee_id"]       = dbobj.emp_id;
                            vals["currency_id"]       = dbobj.currency_id;

                            var created = Controller.InstanceCreation().UpdateLeave("hr.expense", "app_update_expense", dbobj.id, vals);

                            if (created == "True")
                            {
                                App._connection.Query <ExpenseModelDB>("DELETE FROM ExpenseModelDB WHERE Dbid=?", dbobj.Dbid);

                                App._connection.CreateTable <ExpenseModelDB>();
                                var details        = (from y in App._connection.Table <ExpenseModelDB>() select y).ToList();
                                App.expense_listDb = details;

                                // List<LeavesModel> Data = Controller.InstanceCreation().GetMasterData();

                                Task.Run(() => Controller.InstanceCreation().GetMasterData());
                                MessagingCenter.Send <string, String>("MyApp", "ExpenseListUpdated", "true");
                            }

                            else
                            {
                                //   App._connection.Query<ExpenseModelDB>("DELETE FROM ExpenseModelDB WHERE Dbid=?", dbobj.Dbid);

                                //   App._connection.CreateTable<ExpenseModelDB>();
                                //   var details = (from y in App._connection.Table<ExpenseModelDB>() select y).ToList();
                                //   App.expense_listDb = details;

                                //Task.Run(() => Controller.InstanceCreation().GetMasterData());
                                //MessagingCenter.Send<string, String>("MyApp", "ExpenseListUpdated", "true");
                            }
                        }
                    }

                    //List< TimesheetModelDB> timesheet_edits = App._connection.Query<TimesheetModelDB>("SELECT * from TimesheetModelDB ");

                    //if(timesheet_edits.Count !=0)
                    //{
                    //    foreach (var dbobj in timesheet_edits)
                    //    {

                    //        MessagingCenter.Send<string, TimesheetModelDB>("MyApp", "timesheetUpdate", dbobj);
                    //    }

                    //    System.Diagnostics.Debug.Write("AKILLLLLLLLLLLLLLL" + timesheet_edits);
                    //}

                    return(true);
                });
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }