Пример #1
0
        // Insert Data In FireBase DataBase ...
        //

        public async void FireBase_Insert(Employee Employee)
        {
            IFirebaseConfig Config = new FirebaseConfig
            {
                AuthSecret = "VH1rdiDgj2hzD0WN5JZ67BSXTN7OdOeM0fnry50G",
                BasePath   = "https://ctm-db.firebaseio.com/"
            };

            IFirebaseClient Client = new FireSharp.FirebaseClient(Config);

            var Employee_Data = new FireBase_Employee
            {
                Number      = Employee.Get_Number(),
                Name        = Employee.Get_Name(),
                Connect1    = Employee.Get_Connect1(),
                Connect2    = Employee.Get_Connect2(),
                Children    = Employee.Get_Children(),
                Type        = Employee.Get_Type(),
                Class       = Employee.Get_Class(),
                Number_Hour = Employee.Get_Number_Hour(),
                Detail      = Employee.Get_Detail()
            };

            SetResponse Respose = await Client.SetTaskAsync("Employee/" + Employee.Get_Number(), Employee_Data);

            return;
        }
        public async void Excute_Process(Process Process)
        {
            IFirebaseConfig Config = new FirebaseConfig
            {
                AuthSecret = "VH1rdiDgj2hzD0WN5JZ67BSXTN7OdOeM0fnry50G",
                BasePath   = "https://ctm-db.firebaseio.com/"
            };

            IFirebaseClient Client = new FireSharp.FirebaseClient(Config);

            if (Process.Code == "S1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Student/" + Process.Record_Id);

                FireBase_Student Data = Respose.ResultAs <FireBase_Student>();

                Student Student = new Student(Data.Id, Data.First_Name, Data.Last_Name, Data.Father_Name, Data.Birth, Data.Type, Data.Connect1, Data.Connect2,
                                              Data.Class, Data.Registration, Data.School_Name, Data.Transportation, Data.City, Data.Block,
                                              Data.Street, Data.Detail, Data.Account_Number, Data.File_Number, Data.Note, Data.File_Stutus, Data.Picture);
                Student.Sql_Insert(Student);
                return;
            }
            else if (Process.Code == "S2")
            {
                Student Student = new Student();
                Student.Sql_Delete(Process.Record_Id);
                return;
            }
            else if (Process.Code == "S3")
            {
                return;
            }
            else if (Process.Code == "R1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Receipt/" + Process.Record_Id);

                FireBase_Receipt Data = Respose.ResultAs <FireBase_Receipt>();

                Receipt Receipt = new Receipt(Data.Number, Data.Book, Data.Branch, Data.Recipient,
                                              Data.First_Name, Data.Last_Name, Data.Amount_Paid, Data.Date, Data.For, Data.Account_Number);
                Receipt.Sql_Insert(Receipt);
                return;
            }
            else if (Process.Code == "R2")
            {
                Receipt Receipt = new Receipt();
                Receipt.Sql_Delete(Process.Record_Id);
            }
            else if (Process.Code == "R3")
            {
                return;
            }
            else if (Process.Code == "A1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Account/" + Process.Record_Id);

                FireBase_Account Data = Respose.ResultAs <FireBase_Account>();

                Respose = await Client.GetTaskAsync("Number_Account_Detail/" + "Now");

                FireBase_Account_Detail_Counter Counter_Data = Respose.ResultAs <FireBase_Account_Detail_Counter>();

                List <Receipt> Receipts = new List <Receipt>();

                int Number_Detail = int.Parse(Counter_Data.Counter);

                List <Account_Detail> Detail = new List <Account_Detail>();

                for (int i = 1; i < Number_Detail; i++)
                {
                    Respose = await Client.GetTaskAsync("Account_Detail/" + i.ToString());

                    FireBase_Account_Detail Detail_Data = Respose.ResultAs <FireBase_Account_Detail>();

                    if (Detail_Data.Account_Id == Process.Record_Id)
                    {
                        Account_Detail Account_Detail = new Account_Detail(Detail_Data.Account_Id, Detail_Data.Student_Name, Detail_Data.Class, Detail_Data.Registration_Fee, Detail_Data.Study_Fee, Detail_Data.Transportaion_Fee, Detail_Data.Extra_Fee, Detail_Data.Total);
                        Detail.Add(Account_Detail);
                    }
                }


                Account Account = new Account(Data.Number, Data.Name, Data.Type, Data.Connect1, Data.Connect2, Data.Whats_App, Data.Total, Data.Amount_Paid, Data.Remender, Receipts, Detail);

                Account.Sql_Insert(Account);

                return;
            }
            else if (Process.Code == "A2")
            {
                Account Account = new Account();
                Account.Sql_Delete(Process.Record_Id);

                Account_Detail Account_Detail = new Account_Detail();
                Account_Detail.Sql_Delete(Process.Record_Id);

                return;
            }
            else if (Process.Code == "A3")
            {
                return;
            }
            else if (Process.Code == "E1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Employee/" + Process.Record_Id);

                FireBase_Employee Data = Respose.ResultAs <FireBase_Employee>();

                List <Employee_Receipt> Employee_Receipt = new List <Employee_Receipt>();

                Employee Employee = new Employee(Data.Number, Data.Name, Data.Connect1, Data.Connect2, Data.Children, Data.Type, Data.Class, Data.Number_Hour, Data.Detail, Employee_Receipt);
                Employee.Sql_Insert(Employee);
                return;
            }
            else if (Process.Code == "E2")
            {
                Employee Employee = new Employee();
                Employee.Sql_Delete(Process.Record_Id);
                return;
            }
            else if (Process.Code == "E3")
            {
                return;
            }
            else if (Process.Code == "SA1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Employee_Receipt/" + Process.Record_Id);

                FireBase_Employee_Receipt Data = Respose.ResultAs <FireBase_Employee_Receipt>();

                Employee_Receipt Employee_Receipt = new Employee_Receipt(Data.Number, Data.Book, Data.Owner, Data.Date,
                                                                         Data.Name, Data.Sallary, Data.Discount, Data.Total, Data.Detail, Data.Employee_Number);
                Employee_Receipt.Sql_Insert(Employee_Receipt);
                return;
            }
            else if (Process.Code == "SA2")
            {
                return;
            }
            else if (Process.Code == "SA3")
            {
                return;
            }
            else if (Process.Code == "MR1")
            {
                FirebaseResponse Respose = await Client.GetTaskAsync("Movement_Receipt/" + Process.Record_Id);

                FireBase_Movement_Receipt Data = Respose.ResultAs <FireBase_Movement_Receipt>();

                Movement_Receipt Movement_Receipt = new Movement_Receipt(Data.Number, Data.Book, Data.Type, Data.Owner, Data.Kind, Data.Amount, Data.Date, Data.Detail);

                Movement_Receipt.Sql_Insert(Movement_Receipt);
                return;
            }
            else if (Process.Code == "MR2")
            {
                return;
            }
            else if (Process.Code == "MR3")
            {
                return;
            }
        }