private async Task XEditMode()
        {
            //var a = LoadImage(studimg.ImageSource);
            //Image temp = new Bitmap();
            //try
            //{
            Sqlcmd.Parameters.Clear();
            //var strm = new MemoryStream();
            ////temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
            //_imagebytearray = strm.ToArray();
            byte[] temp = ImageHelper.ImageSourceToBytes(new JpegBitmapEncoder(), studimg.ImageSource);
            //MemoryStream strm = new();
            //temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
            //var a=
            _imagebytearray = temp.ToArray();
            await Conopen();

            Strsql =
                "Update tbl_Students set stud_id=@stud_id, Stud_FName=@Stud_FName, Stud_LName=@Stud_LName, Stud_MInit=@Stud_MInit," +
                "Crs_Description=@Crs_Description,Yr_Level=@Yr_Level,stud_img=@stud_img, vtc_desc=@vtc_desc Where stud_id=@_preID";

            Sqlcmd.Parameters.AddWithValue("@stud_id", studid.Text);
            Sqlcmd.Parameters.AddWithValue("@Stud_LName", lname.Text);
            Sqlcmd.Parameters.AddWithValue("@Stud_FName", fname.Text);
            Sqlcmd.Parameters.AddWithValue("@Stud_MInit", minitial.Text);
            Sqlcmd.Parameters.AddWithValue("@Crs_Description", course.Text);
            Sqlcmd.Parameters.AddWithValue("@Yr_Level", yrlevel.Text);
            Sqlcmd.Parameters.AddWithValue("@stud_img", _imagebytearray);
            Sqlcmd.Parameters.AddWithValue("@vtc_desc", vtCategory.Text);
            Sqlcmd.Parameters.AddWithValue("@_preID", SelectedStudId);
            Sqlcmd.Connection = Cnn;
            //sqlcmd.CommandType = CommandType.Text;
            Sqlcmd.CommandText = Strsql;
            await Sqlcmd.ExecuteNonQueryAsync();

            notifier.ShowInformation("Record has been successfully updated!");
            Sqlcmd.Dispose();
            Strsql = "";
            Cnn.Close();
            Close();
            //}
            //catch
            //{

            //    notifier.ShowError("The ID # you've Entered is already in the record! Please verify this problem to the registrar!");
            //    studid.Text = "";
            //    studid.Focus();
            //}
        }
        //Convert byte image to imagesource
        private async Task Xaddmode()
        {
            try
            {
                //This still needs to edit if the students had no picture, the system must still sav the file.
                Sqlcmd.Parameters.Clear();
                Bitmap       temp = new(_selectedFileName);
                MemoryStream strm = new();
                temp.Save(strm, System.Drawing.Imaging.ImageFormat.Jpeg);
                _imagebytearray = strm.ToArray();
                await Conopen();

                Strsql =
                    "Insert into tbl_Students(Stud_Id, Stud_FName, Stud_LName, Stud_MInit,Crs_Description,Yr_Level,stud_img, vtc_desc) " +
                    "Values(@Stud_Id, @Stud_FName, @Stud_LName, @Stud_MInit, @Crs_Description, @Yr_Level,@stud_img, @vtc_desc)";
                Sqlcmd.Parameters.AddWithValue("@Stud_Id", studid.Text);
                Sqlcmd.Parameters.AddWithValue("@Stud_FName", fname.Text);
                Sqlcmd.Parameters.AddWithValue("@Stud_LName", lname.Text);
                Sqlcmd.Parameters.AddWithValue("@Stud_MInit", minitial.Text);
                Sqlcmd.Parameters.AddWithValue("@Crs_Description", course.Text);
                Sqlcmd.Parameters.AddWithValue("@Yr_Level", yrlevel.Text);
                Sqlcmd.Parameters.AddWithValue("@stud_img", _imagebytearray);
                Sqlcmd.Parameters.AddWithValue("@vtc_desc", vtCategory.Text);
                Sqlcmd.Connection  = Cnn;
                Sqlcmd.CommandText = Strsql;
                _ = await Sqlcmd.ExecuteNonQueryAsync();

                Sqlcmd.Dispose();
                Strsql = "";
                Cnn.Close();
                Close();
                notifier.ShowSuccess("Data successfully saved!");
            }
            catch
            {
                notifier.ShowError("The ID # you've Entered is already in the record! Please verify this problem to the registrar!");
                studid.Text = "";
                studid.Focus();
            }
        }