Exemplo n.º 1
0
        public static async void LogIn(bool IsEnter)
        {
            if (IsEnter)
            {
                DataAlreadyLoaded?.Invoke();
                Storage.DataLoaded = true;
            }
            else
            {
                if (Current.Properties.TryGetValue("user", out object id))
                {
                    try
                    {
                        ResultObj result = await Task.Run(() => Users.GetInfoAboutUser((int)id));

                        Storage.User = result.User;
                        Storage.User.AddPhoto(Photo.Get(Storage.User.Id).Image);
                        ResultObj blood = BloodData.Get(result.User.Id);
                        Storage.User.AddBloodGroup(blood.BloodGroup);
                        Storage.User.AddRFactor(blood.RFactor);
                        DataAlreadyLoaded?.Invoke();
                        Storage.DataLoaded = true;
                    }
                    catch (System.Exception ex)
                    {
                        string str = ex.Message;
                        Current.MainPage = new NavigationPage(new EnterPage());
                    }
                }
            }
        }
Exemplo n.º 2
0
 private void insertUserBloodDataTable()
 {
     if (this.userAddressTable != null)
     {
         try
         {
             this.userBloodTable            = new BloodData();
             this.userBloodTable.userID     = this.txtboxUserName.Text;
             this.userBloodTable.bloodGroup = this.bloodGroup;
             this.userBloodTable.month      = 0;
             this.userBloodTable.date       = null;
             this.userBloodTable.donated    = 0;
             this.userBloodTable.requested  = 0;
             if (this.bloodReportStatus)
             {
                 this.userBloodTable.bloodReport = 1;
             }
             else
             {
                 this.userBloodTable.bloodReport = 0;
             }
             this.userBloodTable.accountstatus = "pending";
             db.BloodDatas.InsertOnSubmit(this.userBloodTable);
             db.SubmitChanges();
         }catch (SqlException ex)
         {
             MessageBox.Show("BloodDataTable Not Created");
         }
     }
     else
     {
         MessageBox.Show("Address Table Is Must Be Created First");
     }
 }
        private void checkVerificationCode()
        {
            DB_contextDataContext db             = new DB_contextDataContext();
            UserLoginData         logindataTable = db.UserLoginDatas.SingleOrDefault(x => x.username == this.LoggedUName);
            UserAddr  userAddresTab    = db.UserAddrs.SingleOrDefault(x => x.userID == this.LoggedUName);
            UserDtail userDetailsTable = db.UserDtails.SingleOrDefault(x => x.userID == this.LoggedUName);
            BloodData userBloodTable   = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);

            if (logindataTable != null && userAddresTab != null && userDetailsTable != null && userBloodTable != null)
            {
                if (logindataTable.verfication == code)
                {
                    logindataTable.confirmVerification = this.txtConfirm.Text;
                    userAddresTab.accountstatus        = "activated";
                    userDetailsTable.accountstatus     = "activated";
                    userBloodTable.accountstatus       = "activated";
                    db.SubmitChanges();
                    this.userLoginForm.isChecked = true;
                    this.lableStatus.Text        = "Account Activating.....";
                    Thread.Sleep(4000);
                    userHomePage userForm = new userHomePage();
                    userForm.showLoggedUser(LoggedUName);
                    this.Hide();
                    userForm.Show();
                }
                else
                {
                    this.lableStatus.Text = "Invalid Code";
                    this.txtConfirm.Clear();
                }
            }
        }
Exemplo n.º 4
0
        public async void ShowAuthor(int id)
        {
            try
            {
                if (id != Storage.User.Id)
                {
                    Storage.Friend = Users.GetInfoAboutUser(id).User;
                    Storage.Friend.AddPhoto(Photo.Get(id).Image);
                    ResultObj result = BloodData.Get(id);
                    Storage.Friend.AddBloodGroup(result.BloodGroup);
                    Storage.Friend.AddRFactor(result.RFactor);
                    Storage.IsUserNow = false;
                }
                else
                {
                    Storage.IsUserNow = true;
                }
                await Navigation.PushModalAsync(new Profile());

                Storage.Friend = null;
                System.GC.Collect();
            }
            catch (System.Exception ex)
            {
                await DisplayAlert("Ошибка", ex.Message, "OK");
            }
        }
Exemplo n.º 5
0
        private void deleteBloodData()
        {
            BloodData bloodDataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.uName);

            if (bloodDataTable != null)
            {
                db.BloodDatas.DeleteOnSubmit(bloodDataTable);
                //db.SubmitChanges();
            }
        }
Exemplo n.º 6
0
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (this.reqType.Equals("donate"))
     {
         BloodData bloodDataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);
         //UserDtail userDetailTable = db.UserDtails.SingleOrDefault(x => x.userID == this.LoggedUName);
         if (bloodDataTable != null)
         {
             if (bloodDataTable.bloodReport == 1) //checking blood report pos or neg
             {
                 this.bloodGroup = bloodDataTable.bloodGroup;
                 if (this.checkLastGivenDate())
                 {
                     this.addToTempTable();
                     //this.addToBloodInventory();
                 }
                 else
                 {
                     MessageBox.Show("U can not donate before 3 months");
                     this.LableStatus.Text = "Last Donated : " + bloodDataTable.date;
                     //
                 }
             }
             else
             {
                 this.LableStatus.Text = "You Can Not Donate,Your Blood Report is negetive";
             }
         }
     }
     else if (this.reqType.Equals("request"))
     {
         if (!string.IsNullOrEmpty(this.txtBloodQuantity.Text))
         {
             int userRequested = int.Parse(this.txtBloodQuantity.Text);
             if (userRequested >= 0 && userRequested <= this.bloodQuantity)
             {
                 this.addToTempTable();
                 //this.updateBloodQuantity(userRequested);
             }
             else
             {
                 MessageBox.Show("Blood Unavailable");
             }
             this.LableStatus.Text = this.bloodGroup + " : " + this.bloodQuantity;
         }
     }
     else
     {
     }
 }
Exemplo n.º 7
0
        private bool updateBloodData()
        {
            BloodData bloodData = db.BloodDatas.SingleOrDefault(x => x.userID == this.uName);

            if (bloodData != null)
            {
                bloodData.userID = this.txtUserName.Text;
                db.SubmitChanges();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 8
0
        private void addToBloodInventory() //only for donation
        {
            BloodData      bdataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);
            BloodInventory bloodTable = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup);

            if (bloodTable != null && bdataTable != null)
            {
                this.date = DateTime.Now;
                bloodTable.bloodquantity += 1;
                bdataTable.donated       += 1;
                bdataTable.date           = date.ToString();
                bdataTable.month          = int.Parse(date.Month.ToString());
                db.SubmitChanges();
                this.addToHistory(1);
                this.LableStatus.Text = bloodTable.bloodgroup + " : Blood Donated " + bloodTable.bloodquantity.ToString();
            }
        }
Exemplo n.º 9
0
        public async void ConfirmButton_Clicked(object sender, EventArgs e)
        {
            if (CodeEntry.Text != Storage.ConfirmCode)
            {
                await DisplayAlert("Ошибка", "Неверный код!\nПопробуйте ещё раз", "OK");
            }
            else
            {
                activityIndicator.Start();
                string res = "", res1 = "";
                if (Storage.IsEntering)
                {
                    Storage.User       = Storage.temporaryData;
                    Storage.IsEntering = false;
                    App.Current.Properties.Clear();
                    App.Current.Properties.Add("user", Storage.User.Id);
                    App.LogIn(true);
                    await Navigation.PushAsync(new MainPage());

                    return;
                }
                else
                {
                    res = await Task.Run(() => Registration.Add(Storage.temporaryData));

                    res1 = await Task.Run(() => BloodData.Push(Storage.temporaryData.Id, Storage.temporaryData.BloodGroup,
                                                               Storage.temporaryData.RFactor));
                }
                activityIndicator.Stop();
                if (res == "OK" && res1 == "OK")
                {
                    await Navigation.PopToRootAsync();
                }
                else if (res == "OK")
                {
                    await DisplayAlert("Предупреждение", "Возможно данные крови не были добавлены", "OK");

                    await Navigation.PopToRootAsync();
                }
                else
                {
                    await DisplayAlert("Ошибка", "Некорректные данные или проблемы с интернетом", "OK");
                }
            }
        }
Exemplo n.º 10
0
    public BloodData getBlood(String Blood_Code)
    {
        BloodData Blood_data = new BloodData();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From BLOOD Where BLOOD_CODE='" + Blood_Code + "'";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            Blood_data.Blood_Code = rowData["BLOOD_CODE"].ToString();
            Blood_data.Blood_Name = rowData["BLOOD_NAME"].ToString();
        }

        return(Blood_data);
    }
Exemplo n.º 11
0
 public async void SaveButton_Clicked(object sender, EventArgs e)
 {
     if (CheckData())
     {
         Client client = CreateUser();
         string str    = Registration.Change(client);
         string mess   = BloodData.Push(client.Id, client.BloodGroup, client.RFactor);
         if (str == "OK" && mess == "OK")
         {
             Storage.User = client;
             await Navigation.PopModalAsync();
         }
         else
         {
             await DisplayAlert("Ошибка", "Некорректные данные или проблемы с интернетом", "OK");
         }
     }
 }
Exemplo n.º 12
0
    public List <BloodData> getBlood()
    {
        List <BloodData> Blood_data = new List <BloodData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From BLOOD Order By BLOOD_CODE";
        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            BloodData Blood = new BloodData();
            Blood.Blood_Code = rowData["BLOOD_CODE"].ToString();
            Blood.Blood_Name = rowData["BLOOD_NAME"].ToString();
            Blood_data.Add(Blood);
        }

        return(Blood_data);
    }
Exemplo n.º 13
0
        private void lastDonated()
        {
            BloodData bdataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);

            if (bdataTable != null)
            {
                if (bdataTable.date != null && bdataTable.donated > 0)
                {
                    this.LableStatus.Text = "Last Donated : " + bdataTable.date;
                }
                else
                {
                    this.LableStatus.Text = "Never Donated Before";
                }
            }
            else
            {
                MessageBox.Show("BloodData Table Error");
            }
        }
Exemplo n.º 14
0
        private void updateBloodQuantity(int uReqQuantity) //only for request blood
        {
            BloodData      bDataTable    = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);
            BloodInventory bloodInvTable = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup);

            if (bloodInvTable != null && bDataTable != null)
            {
                this.bloodQuantity -= uReqQuantity;
                //i was here
                bloodInvTable.bloodquantity = this.bloodQuantity;
                //db.SubmitChanges();
                bDataTable.requested += int.Parse(this.txtBloodQuantity.Text.ToString()); //it was not updating
                db.SubmitChanges();
                this.addToHistory(uReqQuantity);
                MessageBox.Show("Request Accepted" + bDataTable.requested.ToString());
            }
            else
            {
                MessageBox.Show("DB not Updated");
            }
        }
Exemplo n.º 15
0
        private void setFromDataBase()
        {
            DB_contextDataContext db = new DB_contextDataContext();
            UserDtail             userDetailTable = new UserDtail();

            this.userAddressTable   = db.UserAddrs.SingleOrDefault(x => x.userID == this.uName);
            this.userBloodDataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.uName);
            userDetailTable         = db.UserDtails.SingleOrDefault(x => x.userID == this.uName);
            if (this.userAddressTable != null && this.userBloodDataTable != null && userDetailTable != null)
            {
                this.txtFirstName.Text   = this.userAddressTable.firstName;
                this.txtLastName.Text    = this.userAddressTable.lastName;
                this.txtUserName.Text    = this.userAddressTable.userID;
                this.txtPhone.Text       = this.userAddressTable.mobileNo;
                this.txtEmail.Text       = this.userAddressTable.email;
                this.txtDistrict.Text    = this.userAddressTable.district;
                this.txtSubdistrict.Text = this.userAddressTable.subDistrict;
                this.txtPostal.Text      = this.userAddressTable.postalCode;
                this.LableBlood.Text     = this.userBloodDataTable.bloodGroup;
                try
                {
                    this.userPP.Image = Image.FromFile(userDetailTable.propicture);
                }
                catch (ArgumentNullException exp)
                {
                    this.userPP.Image = Image.FromFile(@"F:\Programming\C#\C# Project Updated\BloodBankManagement\BloodBankManagement\images\default.jpg");
                }

                //this.userPP.SizeMode = PictureBoxSizeMode.StretchImage;
                this.userPP.SizeMode = PictureBoxSizeMode.Zoom;
            }
            else
            {
                this.lableValidation.Text = "Problem To Load Database";
                //MessageBox.Show("Problem To Load Database");
            }
        }
Exemplo n.º 16
0
        private bool checkLastGivenDate()
        {
            BloodData bdataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName);

            if (bdataTable != null)
            {
                int Lastmonth     = bdataTable.month ?? default(int);
                int currmonth     = int.Parse(DateTime.Now.Month.ToString());
                int monthDuration = currmonth - Lastmonth;
                if (monthDuration >= 3)
                {
                    this.btnSubmit.Enabled = true;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 17
0
 private async void ResultList_ItemTapped(object sender, ItemTappedEventArgs e)
 {
     try
     {
         ResultList.IsEnabled = false;
         if (e.Item != null)
         {
             UserModel userView = (UserModel)e.Item;
             int       id       = userView.ModeID;
             if (id != -1)
             {
                 if (id != Storage.User.Id)
                 {
                     Storage.Friend = Users.GetInfoAboutUser(id).User;
                     Storage.Friend.AddPhoto(Photo.Get(id).Image);
                     ResultObj result = BloodData.Get(id);
                     Storage.Friend.AddBloodGroup(result.BloodGroup);
                     Storage.Friend.AddRFactor(result.RFactor);
                     Storage.IsUserNow = false;
                 }
                 else
                 {
                     Storage.IsUserNow = true;
                 }
                 await Navigation.PushAsync(new Profile());
             }
         }
         ((ListView)sender).SelectedItem = null;
         ResultList.IsEnabled            = true;
         System.GC.Collect();
     }
     catch (System.Exception ex)
     {
         await DisplayAlert("Error", ex.Message, "OK");
     }
 }
Exemplo n.º 18
0
        private async void EnterButton_Clicked(object sender, EventArgs e)
        {
            try
            {
                EnterButton.IsEnabled = false;
                IsBusy = true;

                if (!IsCheck)
                {
                    EnterButton.Text = "Войти";
                    CheckParams();
                    Password.PlaceholderColor = Color.LightGray;
                    Password.IsVisible        = true;
                    IsCheck = true;
                }
                else
                {
                    if (CrossConnectivity.Current.IsConnected)
                    {
                        if (CheckParams())
                        {
                            ResultObj result = await Task.Run(() => DonorPlusLib.Login.CheckLogin(Login.Text.Trim(), Password.Text));

                            if (result.ErrorMessage == "OK")
                            {
                                Storage.User = result.User;
                                Storage.User.AddPhoto(Photo.Get(result.User.Id).Image);
                                ResultObj blood = BloodData.Get(result.User.Id);
                                Storage.User.AddBloodGroup(blood.BloodGroup);
                                Storage.User.AddRFactor(blood.RFactor);


                                if (Storage.IsMailsAvaliable)
                                {
                                    SendEmailAsync(Storage.User.Email).GetAwaiter();
                                }

                                App.Current.Properties.Clear();

                                App.Current.Properties.Add("user", result.User.Id);

                                if (Navigation.NavigationStack.Count == 1)
                                {
                                    App.Current.MainPage = new NavigationPage(new MainPage());
                                }
                                else
                                {
                                    await Navigation.PushModalAsync(new MainPage());
                                }
                                App.LogIn(true);
                            }
                            else
                            {
                                IsBusy = false;
                                await DisplayAlert("Ошибка", "Некорректные данные или проблемы с интернетом", "ОК");
                            }
                        }
                    }
                    else
                    {
                        await DisplayAlert("Интернет отсутствует", "Подключите интернет", "ОК");
                    }
                }
                IsBusy = false;
                EnterButton.IsEnabled = true;
            }
            catch (Exception ex)
            {
                await DisplayAlert("Ошибка", $"{ex.Message}", "OK");

                EnterButton_Clicked(sender, e);
            }
        }