Beispiel #1
0
        public List <ExpenseModel> GetExpenseData()
        {
            List <ExpenseModel> tsdata = new List <ExpenseModel>();
            JArray result = odooConnector.odooMethodCall_gettimesheet <JArray>("hr.expense", "get_expense");

            tsdata = result.ToObject <List <ExpenseModel> >();

            App.expense_list = tsdata;

            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(tsdata);
        }
Beispiel #2
0
 private void Expenselist_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     if (CrossConnectivity.Current.IsConnected)
     {
         try
         {
             ExpenseModel data = (ExpenseModel)e.Item;
             Navigation.PushAsync(new ExpenseDetailPage(data));
         }
         catch (Exception exce)
         {
             ExpenseModelDB data = (ExpenseModelDB)e.Item;
             Navigation.PushAsync(new ExpenseDetailPage(data));
         }
     }
     else
     {
         try
         {
             ExpenseModelDB data = (ExpenseModelDB)e.Item;
             Navigation.PushAsync(new ExpenseDetailPage(data));
         }
         catch
         {
             ExpenseModel data = (ExpenseModel)e.Item;
             Navigation.PushAsync(new ExpenseDetailPage(data));
         }
     }
 }
Beispiel #3
0
        private async void createbtn_ClickedAsync(object sender, EventArgs e)
        {
            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();

            int emp_id = (App.employee_list.AsEnumerable().Where(p => p.name == employee_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();
            int cur_id = (App.currencyList.AsEnumerable().Where(p => p.Name == currency_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();

            List <dynamic> attfile = new List <dynamic>();

            foreach (var data in attach)
            {
                Dictionary <string, dynamic> dict = new Dictionary <string, dynamic>();

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

            if (description.Text == "")
            {
                exdes_alert.IsVisible   = true;
                product_alert.IsVisible = false;
            }

            else if (searchprod.Text == "")
            {
                product_alert.IsVisible = true;
                exdes_alert.IsVisible   = false;
            }

            else
            {
                if (App.NetAvailable == true)
                {
                    //var currentpage = new LoadingIndicator();
                    //await PopupNavigation.Instance.PushAsync(currentpage);
                    act_ind.IsRunning = true;

                    product_alert.IsVisible = false;
                    exdes_alert.IsVisible   = false;

                    vals["name"]           = description.Text;
                    vals["product_id"]     = exp_prod_id;
                    vals["unit_amount"]    = unit_price.Text;
                    vals["quantity"]       = qty.Text;
                    vals["product_uom_id"] = uom_id;
                    vals["reference"]      = bill_ref.Text;
                    vals["date"]           = start_date.Date.ToString("yyyy-MM-dd");
                    vals["employee_id"]    = emp_id;
                    vals["currency_id"]    = cur_id;
                    vals["total_amount"]   = total;
                    vals["attachment"]     = attfile;
                    var created = Controller.InstanceCreation().CreateLeave("hr.expense", "app_create_expense", vals);

                    if (created == "True")
                    {
                        await Task.Run(() => App.Current.MainPage = new MasterPage(new ExpensePage()));

                        Loadingalertcall();
                        act_ind.IsRunning = false;
                        DependencyService.Get <Toast>().Show("Created Successfully...");
                    }
                    else
                    {
                        //  Loadingalertcall();
                        act_ind.IsRunning = false;
                        DependencyService.Get <Toast>().Show(created);
                    }
                }
                else
                {
                    act_ind.IsRunning = true;
                    var jso_attchment_list = Newtonsoft.Json.JsonConvert.SerializeObject(attfile);

                    DateTime dt = DateTime.ParseExact(start_date.Date.ToString("yyyy-MM-dd"), "yyyy-MM-dd", null);
                    string   convert_halfdate = dt.ToLocalTime().ToString("MMMM dd");

                    var sample = new ExpenseModelDB
                    {
                        name                = description.Text,
                        product             = searchprod.Text,
                        product_id          = exp_prod_id,
                        unit_price          = float.Parse(unit_price.Text),
                        uom_id              = uom_id,
                        quantity            = float.Parse(qty.Text),
                        reference           = bill_ref.Text,
                        sync_string         = "sync.png",
                        stage_colour        = "#008FD3",
                        stage_name          = "To Submit",
                        state               = "draft",
                        attachment          = jso_attchment_list,
                        date                = start_date.Date.ToString("yyyy-MM-dd"),
                        half_date           = convert_halfdate,
                        employee_id         = employee_picker.SelectedItem.ToString(),
                        emp_id              = emp_id,
                        currency            = currency_picker.SelectedItem.ToString(),
                        currency_id         = cur_id,
                        total               = total,
                        check_rpc_condition = "true",
                        // error_attachment_list = attach_list,
                    };
                    App._connection.Insert(sample);

                    App._connection.CreateTable <ExpenseModelDB>();
                    try
                    {
                        var details = (from y in App._connection.Table <ExpenseModelDB>() select y).ToList();
                        App.expense_listDb = details;
                    }
                    catch (Exception ex)
                    {
                        int i = 0;
                    }
                    await Task.Run(() => App.Current.MainPage = new MasterPage(new ExpensePage()));

                    DependencyService.Get <Toast>().Show("Created successfully need to sync with server...");
                    act_ind.IsRunning = false;
                    Loadingalertcall();
                }
            }

            //  PopupNavigation.Instance.PopAsync();
        }
Beispiel #4
0
        private async void update_clickedAsync(object sender, EventArgs e)
        {
            Dictionary <string, dynamic> vals = new Dictionary <string, dynamic>();

            if (expdescription_entry.Text == "")
            {
                exdes_alert.IsVisible   = true;
                product_alert.IsVisible = false;
            }

            else if (searchprod.Text == "")
            {
                product_alert.IsVisible = true;
                exdes_alert.IsVisible   = false;
            }

            else
            {
                act_ind.IsRunning = true;
                //var currentpage = new LoadingIndicator();
                //await PopupNavigation.Instance.PushAsync(currentpage);

                product_alert.IsVisible = false;
                exdes_alert.IsVisible   = false;

                vals["name"]           = expdescription_entry.Text;
                vals["product_id"]     = exp_prod_id;
                vals["unit_amount"]    = price_entry.Text;
                vals["quantity"]       = qty.Text;
                vals["product_uom_id"] = uom_id;
                vals["reference"]      = reference_entry.Text;

                vals["date"] = start_date.Date.ToString("yyyy-MM-dd");

                //  vals["total_amount"] = total;

                List <dynamic> attfile = new List <dynamic>();
                foreach (var data in attach)
                {
                    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["add_attachment"] = attfile;

                vals["remove_attachment"] = delete_attach;

                if (CrossConnectivity.Current.IsConnected)
                {
                    int emp_id = (App.employee_list.AsEnumerable().Where(p => p.name == employee_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();
                    int cur_id = (App.currencyList.AsEnumerable().Where(p => p.Name == currency_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();

                    vals["employee_id"] = emp_id;
                    vals["currency_id"] = cur_id;

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

                    if (created == "True")
                    {
                        App.Current.MainPage = new MasterPage(new ExpensePage());

                        // Loadingalertcall();

                        act_ind.IsRunning = false;

                        DependencyService.Get <Toast>().Show("Updated Successfully...");
                    }
                    else
                    {
                        //  Loadingalertcall();
                        DependencyService.Get <Toast>().Show(created);

                        act_ind.IsRunning = false;
                    }
                }

                else
                {
                    int emp_id           = (App.employee_listDb.AsEnumerable().Where(p => p.name == employee_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();
                    int cur_id           = (App.currencyListDb.AsEnumerable().Where(p => p.Name == currency_picker.SelectedItem.ToString()).Select(p => p.id)).FirstOrDefault();
                    int edit_exp_prod_id = (App.expense_productListDb.AsEnumerable().Where(p => p.Name == searchprod.Text.ToString()).Select(p => p.id)).FirstOrDefault();
                    int edit_exp_uom_id  = (App.expense_productListDb.AsEnumerable().Where(p => p.Name == searchprod.Text.ToString()).Select(p => p.uom_id)).FirstOrDefault();

                    string jso_addattchment_list    = "";
                    string jso_removeattchment_list = "";

                    try
                    {
                        jso_addattchment_list = Newtonsoft.Json.JsonConvert.SerializeObject(attfile);
                    }

                    catch
                    {
                        int j = 0;
                    }

                    try
                    {
                        jso_removeattchment_list = Newtonsoft.Json.JsonConvert.SerializeObject(delete_attach);
                    }
                    catch
                    {
                        int jk = 0;
                    }

                    DateTime dt = DateTime.ParseExact(start_date.Date.ToString("yyyy-MM-dd"), "yyyy-MM-dd", null);
                    string   convert_halfdate = dt.ToLocalTime().ToString("MMMM dd");

                    var itemToRemove = App.expense_listDb.Single(r => r.id == expobjDb.id);
                    App.expense_listDb.Remove(itemToRemove);

                    App._connection.Query <ExpenseModelDB>("DELETE FROM [ExpenseModelDB] WHERE [id] = " + expobjDb.id);

                    var sample = new ExpenseModelDB
                    {
                        id                = expobjDb.id,
                        name              = expdescription_entry.Text,
                        product           = searchprod.Text,
                        product_id        = edit_exp_prod_id,
                        unit_price        = float.Parse(price_entry.Text),
                        uom_id            = edit_exp_uom_id,
                        quantity          = float.Parse(qty.Text),
                        reference         = reference_entry.Text,
                        sync_string       = "editexp.png",
                        stage_colour      = expobjDb.stage_colour,
                        stage_name        = expobjDb.stage_name,
                        state             = expobjDb.state,
                        attachment        = jso_addattchment_list,
                        remove_attachment = jso_removeattchment_list,
                        date              = start_date.Date.ToString("yyyy-MM-dd"),
                        half_date         = convert_halfdate,
                        employee_id       = employee_picker.SelectedItem.ToString(),
                        emp_id            = emp_id,
                        currency          = currency_picker.SelectedItem.ToString(),
                        currency_id       = cur_id,
                        //   total = total,
                        check_rpc_condition = "edit",
                        // error_attachment_list = attach_list,
                    };
                    App._connection.Insert(sample);

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

                        App.Current.MainPage = new MasterPage(new ExpensePage());
                        DependencyService.Get <Toast>().Show("Updated locally...");
                    }
                    catch (Exception ex)
                    {
                        int i = 0;
                        act_ind.IsRunning = false;
                    }

                    act_ind.IsRunning = false;
                }
            }
        }
Beispiel #5
0
        public ExpenseDetailPage(ExpenseModelDB obj)
        {
            InitializeComponent();

            expobjDb = obj;

            description_Name.Text = obj.name;
            productlabel.Text     = obj.product;


            //  datelabel.IsVisible = true;

            //DateTime dt = DateTime.ParseExact(obj.date, "yyyy-MM-dd", null);
            //string convert = dt.ToLocalTime().ToString("dd/MM/yyyy");

            //  dateentry.Text = obj.date;

            datelabel.Text = obj.date;

            referencelabel.Text = obj.reference;

            searchprod.Text = expobjDb.product;

            //if(obj.currencyName.Equals("IDR"))
            //{
            //    pricelabel.Text = obj.unit_amount + " " + "RP";
            //}
            //else
            //{
            //    pricelabel.Text = obj.unit_amount.ToString();
            //}

            pricelabel.Text = obj.unit_price.ToString();

            qtylabel.Text       = obj.quantity + " " + obj.product_uom;
            referencelabel.Text = obj.reference;
            // datelabel.Text = obj.full_date;
            //  accountlabel.Text = obj.account;
            employeelabel.Text = obj.employee_id;
            currencylabel.Text = obj.currency;

            if (obj.state.Equals("draft"))
            {
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.stage_name;
            }
            else if (obj.state.Equals("reported"))
            {
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.stage_name;
            }
            else if (obj.state.Equals("done"))
            {
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.stage_name;
            }
            else
            {
                frame_state_color.BackgroundColor = Color.FromHex(obj.stage_colour);
                statelabel.Text = obj.stage_name;
            }

            attachviewlist.IsEnabled = true;
            add_attachment.IsEnabled = true;


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

            var editRecognizer = new TapGestureRecognizer();

            editRecognizer.Tapped += (s, e) =>
            {
                if (CrossConnectivity.Current.IsConnected)
                {
                    attachviewlist.IsEnabled = true;

                    //  attach_layout.IsEnabled = true;

                    edit.IsVisible      = false;
                    updatebtn.IsVisible = true;

                    productlabel.IsVisible   = false;
                    product_layout.IsVisible = true;

                    pricelabel.IsVisible  = false;
                    price_entry.IsVisible = true;
                    price_entry.Text      = obj.unit_price.ToString();

                    qtylabel.IsVisible   = false;
                    qty_layout.IsVisible = true;
                    qty.Text             = obj.quantity.ToString();

                    referencelabel.IsVisible  = false;
                    reference_entry.IsVisible = true;
                    reference_entry.Text      = obj.reference;

                    datelabel.IsVisible   = false;
                    date_layout.IsVisible = true;
                    DateTime date = DateTime.ParseExact(obj.date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    start_date.Date = date;

                    employeelabel.IsVisible   = false;
                    employee_layout.IsVisible = true;
                }
                else
                {
                    attachviewlist.IsEnabled = true;

                    des_layout.IsVisible       = true;
                    description_Name.IsVisible = false;
                    expdescription_entry.Text  = obj.name;

                    //  attach_layout.IsEnabled = true;

                    edit.IsVisible      = false;
                    updatebtn.IsVisible = true;

                    productlabel.IsVisible   = false;
                    product_layout.IsVisible = true;

                    pricelabel.IsVisible  = false;
                    price_entry.IsVisible = true;
                    price_entry.Text      = obj.unit_price.ToString();

                    qtylabel.IsVisible   = false;
                    qty_layout.IsVisible = true;
                    qty.Text             = obj.quantity.ToString();

                    referencelabel.IsVisible  = false;
                    reference_entry.IsVisible = true;
                    reference_entry.Text      = obj.reference;

                    datelabel.IsVisible   = false;
                    date_layout.IsVisible = true;
                    DateTime date = DateTime.ParseExact(obj.date, "yyyy-MM-dd", CultureInfo.InvariantCulture);
                    start_date.Date = date;

                    employeelabel.IsVisible   = false;
                    employee_layout.IsVisible = true;

                    employee_picker.ItemsSource   = App.employee_listDb.Select(n => n.name).ToList();
                    employee_picker.SelectedIndex = 0;
                    employee_picker.SelectedItem  = expobjDb.employee_id;

                    currencylabel.IsVisible   = false;
                    currency_layout.IsVisible = true;

                    currency_picker.ItemsSource   = App.currencyListDb.Select(n => n.Name).ToList();
                    currency_picker.SelectedIndex = 0;
                    currency_picker.SelectedItem  = obj.currency;


                    List <AttachmentFile> attachlistdb = JsonConvert.DeserializeObject <List <AttachmentFile> >(expobjDb.attachment);

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

                    //  DependencyService.Get<Toast>().Show("Need internet connection...");
                }
            };
            edit.GestureRecognizers.Add(editRecognizer);

            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);
        }
Beispiel #6
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);
            }
        }