Example #1
0
        private void loadData()
        {
            // get data
            dsGeneral.dtAppPreferenceDataTable dt = iFacede.GetAppPreference(Globalized.ObjDbName, GlobalObjPreference);
            // intialize object
            if (dt.Rows.Count > 0)
            {
                ObservableCollection <dhAppPreference> listItem = ReflectionUtility.DataTableToObservableCollection <dhAppPreference>(dt);
                if (listItem.Count > 0)
                {
                    GlobalObjPreference         = listItem.Cast <dhAppPreference>().SingleOrDefault();
                    GlobalObjPreference.IUpdate = 1;
                    // GlobalObjPreference.ImgCompanyLogo =(byte[])dt.Rows[0]["imgCompanyLogo"];
                    GlobalObjPreference.ImgCompanyLogo = !string.IsNullOrEmpty(dt.Rows[0]["imgCompanyLogo"].ToString()) ? (byte[])dt.Rows[0]["imgCompanyLogo"] : null;
                    GlobalObjPreference.VCompanyName   = !string.IsNullOrEmpty(dt.Rows[0]["vCompanyName"].ToString()) ? dt.Rows[0]["VCompanyName"].ToString() : null;
                    GlobalObjPreference.VHeaderAdress  = !string.IsNullOrEmpty(dt.Rows[0]["vHeaderAdress"].ToString()) ? dt.Rows[0]["vHeaderAdress"].ToString() : null;
                    GlobalObjPreference.VCompanyMobile = !string.IsNullOrEmpty(dt.Rows[0]["vCompanyMobile"].ToString()) ? dt.Rows[0]["vCompanyMobile"].ToString() : null;
                    //    VSaleType.SelectedItem = GlobalObjPreference.VSaleType;

                    this.DataContext = GlobalObjPreference;
                    cstmUtilities.LoadImage(GlobalObjPreference.ImgCompanyLogo, image1);
                    //VSaleType.SelectedValue = GlobalObjPreference.VSaleType;
                    //Globalized.ObjPrefernce = GlobalObjPreference;
                }
            }
            else
            {
                GlobalObjPreference.IUpdate = 0;
                GlobalObjPreference         = new dhAppPreference();
                this.DataContext            = GlobalObjPreference;
            }
            Globalized.ShowMsg(lblErrorMsg);

            //Globalized.SetMsg(null);
        }
        internal DataSet InsertUpdateAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
        {
            DataSet ds;

            ds = objDALGeneral.InsertUpdateAppPreference(objDBNames, objPreference);
            return(ds);
        }
Example #3
0
        //private void ListViewMenu_SelectionChanged(object sender, SelectionChangedEventArgs e)
        //{
        //    UserControl usc = null;
        //    GridMain.Children.Clear();

        //    switch (((ListViewItem)((ListView)sender).SelectedItem).Name)
        //    {
        //        case "ItemHome":
        //            usc = new PartyView();
        //            GridMain.Children.Add(usc);
        //            break;
        //        case "ItemCreate":
        //            usc = new PartyView();
        //            GridMain.Children.Add(usc);
        //            break;
        //        default:
        //            break;
        //    }
        //}
        private void LoadComponent()
        {
            dhDBnames objDBNames = new dhDBnames();

            objDBNames.ServerName      = System.Configuration.ConfigurationManager.AppSettings["ServerName"].ToString();
            objDBNames.Default_DB_Name = System.Configuration.ConfigurationManager.AppSettings["DBName"].ToString();
            objDBNames.DBUser          = System.Configuration.ConfigurationManager.AppSettings["DBUser"].ToString();
            objDBNames.DBPassword      = System.Configuration.ConfigurationManager.AppSettings["DBPassword"].ToString();
            string path = AppDomain.CurrentDomain.BaseDirectory;//System.Reflection.Assembly.GetExecutingAssembly().Location;

            objDBNames.XmlFilePath = path + "XMLFiles\\" + System.Configuration.ConfigurationManager.AppSettings["DBXmlFilePath"].ToString();
            Globalized.ObjDbName   = objDBNames;

            if (Globalized.objAppPreference == null)
            {
                dsGeneral.dtAppPreferenceDataTable     dtApp    = iFacede.GetAppPreference(Globalized.ObjDbName, objAppPreference);
                ObservableCollection <dhAppPreference> sequence = ReflectionUtility.DataTableToObservableCollection <dhAppPreference>(dtApp);
                if (sequence.Count > 0)
                {
                    objAppPreference = sequence[0];
                    //objAppPreference.ImgCompanyLogo = (System.Byte[])dtApp.Rows[0]["ImgCompanyLogo"];
                    objAppPreference.VEnableModules = string.IsNullOrEmpty(dtApp.Rows[0]["vEnableModules"].ToString()) ? "" : dtApp.Rows[0]["vEnableModules"].ToString();
                    objAppPreference.ImgCompanyLogo = !string.IsNullOrEmpty(dtApp.Rows[0]["imgCompanyLogo"].ToString()) ? (byte[])dtApp.Rows[0]["imgCompanyLogo"] : null;
                    objAppPreference.VCompanyName   = !string.IsNullOrEmpty(dtApp.Rows[0]["vCompanyName"].ToString()) ? dtApp.Rows[0]["VCompanyName"].ToString() : null;
                    Globalized.objAppPreference     = objAppPreference;
                    // cstmUtilities.LoadImage(Globalized.objAppPreference.ImgCompanyLogo, Image1);

                    //  this.AppName.Text = String.IsNullOrEmpty(Globalized.objAppPreference.VApplicationName) ? "POS" : Globalized.objAppPreference.VApplicationName;
                    this.CompanyName.Text = String.IsNullOrEmpty(Globalized.objAppPreference.VCompanyName) ? "ABFA" : Globalized.objAppPreference.VCompanyName;
                    // ModernWindow Obj = (ModernWindow)Application.Current.MainWindow;
                    // Obj.Title = String.IsNullOrEmpty(Globalized.objAppPreference.VApplicationName) ? "POS" : Globalized.objAppPreference.VApplicationName;
                    ////this.lblErrorMsg.Visibility = Visibility.Hidden;
                    ////this.UserName.Text = "";
                    ////this.Password.Password = "";
                    //= sequence;
                }
                else
                {
                    Globalized.SetMsg("Application is Not Initialized Properly please contact support team. ", MsgType.Error);
                    // lblErrorMsg.Visibility = System.Windows.Visibility.Visible;
                    //  Globalized.ShowMsg(lblErrorMsg);
                }
            }
            //byte[] img = (byte[])objAppPreference.ImgCompanyLogo;
            //MemoryStream str = new MemoryStream();
            // str.Write(img, 0, img.Length);
            // BitmapImage  bit = new BitmapImage(str);
            //byte[] objimg = (byte[])objAppPreference.ImgCompanyLogo;
            //imgCompanyLogo.DataContext = ImageFromBytearray(objimg);

            //  byte[] bytImageDataBytes =   objAppPreference.ImgCompanyLogo;
            ////  byte[] bytImageDataBytes = (byte[])objAppPreference.ImgCompanyLogo.;
            //  System.IO.MemoryStream ms = new System.IO.MemoryStream(bytImageDataBytes);
            //  ms.Seek(0, System.IO.SeekOrigin.Begin);
            //  BitmapImage newBitmapImage = new BitmapImage();
            //  newBitmapImage.BeginInit();
            //  newBitmapImage.StreamSource = ms;
            //  newBitmapImage.EndInit();
            //  imgCompanyLogo.Source = newBitmapImage;//ConvertToImage(objAppPreference.ImgCompanyLogo);
        }
Example #4
0
        public ObservableCollection <dhModule> GetUserMenu(dhDBnames objDBNames, dhAppPreference objAppPreference, dhUsers objuser = null)
        {
            DataTable temp        = new DataTable();
            blModule  ObjblModule = new blModule();
            dhModule  objModule   = new dhModule();
            ObservableCollection <dhModule> MenuModule = new ObservableCollection <dhModule>();

            if ((objAppPreference != null) && (objAppPreference.VEnableModules != "") && (objuser != null))
            {
                #region "Allowed Menu"
                objModule.AllowdModule = objAppPreference.VEnableModules;
                dsGeneral.dtPosModuleDataTable dtm = ObjblModule.GetModule(objDBNames, objModule);
                EnumerableRowCollection <dsGeneral.dtPosModuleRow> result2 = from r in dtm.AsEnumerable()
                                                                             where (r.Field <int>("iModuleParentID") == 0) && (r.Field <bool>("bIsActive") == true)
                                                                             select r;
                // if there are any allowed
                int CountRow = result2.Count <dsGeneral.dtPosModuleRow>();
                if (CountRow > 0)
                {
                    DataTable dtResult2 = result2.CopyToDataTable();
                    ObservableCollection <dhModule> sequence = ReflectionUtility.DataTableToObservableCollection <dhModule>(dtResult2);
                    if (sequence.Count > 0)
                    {
                        foreach (dhModule Module in sequence)
                        {
                            string grpkey         = "POS"; //Module.VModuleName;
                            string strDisplayName = Module.VDisplayName;
                            if (objuser.VAllowdModule == null)
                            {
                                if (objuser.VUserType == "Super")
                                {
                                    objuser.VAllowdModule = objAppPreference.VEnableModules;
                                }
                                else
                                {
                                    throw new ApplicationException("Disable User or have no rights.");
                                }
                            }

                            List <string> RootIds          = objuser.VAllowdModule.Split(',').ToList <string>();
                            string        RootAllowdUserID = RootIds.Distinct <string>().Cast <string>().Where(i => i.Equals(Module.IModuleID.ToString())).SingleOrDefault();

                            List <string> RootEnableModulesIds   = objAppPreference.VEnableModules.Split(',').ToList <string>();
                            string        RootAppEnableModulesId = RootEnableModulesIds.Distinct <string>().Cast <string>().Where(i => i.Equals(Module.IModuleID.ToString())).SingleOrDefault();
                            if ((RootAllowdUserID == null) || (RootAppEnableModulesId == null))
                            {
                                continue;
                            }
                            MenuModule.Add(Module);
                        }
                    }// end of dhModule sequence
                }



                #endregion
            }
            return(MenuModule);
        }
Example #5
0
        public static DataSet InsertUpdateAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
        {
            try
            {
                DataSet var_ret;

                if (objBLAppPreference == null)
                {
                    objBLAppPreference = new blAppPreference();
                }
                var_ret = objBLAppPreference.InsertUpdateAppPreference(objDBNames, objPreference);

                return(var_ret);
            }
            catch (Exception ex) { throw ex; }
        }
Example #6
0
 public static ObservableCollection <dhModule> GetUserMenu(dhDBnames objDBNames = null, dhAppPreference objAppPreference = null, dhUsers objuser = null)
 {
     try
     {
         if (objBLUser == null)
         {
             objBLUser = new blUser();
         }
         return(objBLUser.GetUserMenu(objDBNames, objAppPreference, objuser));
     }
     catch (Exception ex) { throw ex; }
 }
Example #7
0
 public static ObservableCollection <dhModule> GetUserSubMenu(dhDBnames objDbName, dhAppPreference objAppPreference, dhUsers objCurrentUser, dhModule objdhModule)
 {
     try
     {
         if (objBLUser == null)
         {
             objBLUser = new blUser();
         }
         return(objBLUser.GetUserSubMenu(objDbName, objAppPreference, objCurrentUser, objdhModule));
     }
     catch (Exception ex) { throw ex; }
 }
Example #8
0
        public static dsGeneral.dtAppPreferenceDataTable GetAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
        {
            try
            {
                dsGeneral.dtAppPreferenceDataTable var_ret = null;

                if (objBLAppPreference == null)
                {
                    objBLAppPreference = new blAppPreference();
                }
                {
                    var_ret = objBLAppPreference.GetAppPreference(objDBNames, objPreference);
                }

                return(var_ret);
            }
            catch (Exception ex) { throw ex; }
        }
Example #9
0
        public static void printDoc(string TemplateName, DataSet ReportDatatables, String ReportName, Boolean ShowPreview = false, string ReportDisc = null)
        {
            //DocumentViewer docview1,
            try
            {
                ReportDocument reportDocument = new ReportDocument();
                StreamReader   reader         = new StreamReader(new FileStream(@"Templates\" + TemplateName, FileMode.Open, FileAccess.Read));
                reportDocument.XamlData      = reader.ReadToEnd();
                reportDocument.XamlImagePath = Path.Combine(Environment.CurrentDirectory, @"Templates\");
                reader.Close();

                ReportData data = new ReportData();
                // Add tables to report Data

                foreach (DataTable DT in ReportDatatables.Tables)
                {
                    //if (DT.Rows.Count < 10)
                    //{
                    //    DataRow abc = null;
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //    DT.Rows.Add(abc);
                    //}
                    data.DataTables.Add(DT);
                }
                data.ReportDocumentValues.Add("PrintDate", DateTime.Now); // print date is now
                dhAppPreference obj = new dhAppPreference();
                dsGeneral.dtAppPreferenceDataTable dt = iFacede.GetAppPreference(Globalized.ObjDbName, obj);
                data.DataTables.Add(dt);

                DateTime dateTimeStart = DateTime.Now; // start time measure here
                data.ReportDocumentValues.Add("ReportDisc", ReportDisc);
                XpsDocument xps = reportDocument.CreateXpsDocument(data);
                // chek have to show or not
                if (!ShowPreview)
                {
                    PrintDialog dlg = new PrintDialog();
                    dlg.PrintDocument(xps.GetFixedDocumentSequence().DocumentPaginator, ReportName);
                }
                else
                {
                    PrintPreview objPre = new PrintPreview();
                    objPre.docview1.Document = xps.GetFixedDocumentSequence();
                    Window window = new Window
                    {
                        Title   = "Print Preview",
                        Content = objPre,
                        Height  = 800, // just added to have a smaller control (Window)
                        Width   = 750
                    };

                    window.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                // show exception
                MessageBox.Show(ex.Message + "\r\n\r\n" + ex.GetType() + "\r\n" + ex.StackTrace, ex.GetType().ToString(), MessageBoxButton.OK, MessageBoxImage.Stop);
            }
        }
Example #10
0
        private void InsertUpdatePreference()
        {
            //FileStream fs = new FileStream(txtFileName.Text.ToString(), FileMode.Open, FileAccess.Read);
            ////Initialize a byte array with size of stream
            //byte[] imgByteArr = new byte[fs.Length];
            ////Read data from the file stream and put into the byte array
            //fs.Read(imgByteArr, 0, Convert.ToInt32(fs.Length));
            //fs.Close();

            GetAllowdModule();
            dhAppPreference objInsert = new dhAppPreference();

            objInsert = (dhAppPreference)this.DataContext;
            if (image1.Source != null)
            {
                byte[] imgByteArr = null;
                if ((image1.Source.Width > 250) || (image1.Source.Height > 100)) //(!ValidFile(image1.Source, 250, 100))
                {
                    BitmapFrame       bframe  = CreateResizedImage(image1.Source, 250, 150, 0);
                    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                    // encoder.Frames.Add(abc);
                    encoder.QualityLevel = 100;
                    imgByteArr           = new byte[0];
                    using (MemoryStream stream = new MemoryStream())
                    {
                        encoder.Frames.Add(bframe);
                        encoder.Save(stream);
                        imgByteArr = stream.ToArray();
                        stream.Close();
                    }
                }
                else
                {
                    BitmapFrame       bframe  = CreateResizedImage(image1.Source, Convert.ToInt32(image1.Source.Width), Convert.ToInt32(image1.Source.Height), 0);
                    JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                    // encoder.Frames.Add(abc);
                    encoder.QualityLevel = 100;
                    imgByteArr           = new byte[0];
                    using (MemoryStream stream = new MemoryStream())
                    {
                        encoder.Frames.Add(bframe);
                        encoder.Save(stream);
                        imgByteArr = stream.ToArray();
                        stream.Close();
                    }
                }

                objInsert.ImgCompanyLogo = imgByteArr;
            }
            else
            {
                objInsert.ImgCompanyLogo = null;
            }

            dhAppPreferenceValidator validator = new dhAppPreferenceValidator();

            FluentValidation.Results.ValidationResult results = validator.Validate(objInsert);

            bool validationSucceeded           = results.IsValid;
            IList <ValidationFailure> failures = results.Errors;

            if (validationSucceeded)
            {
                DataSet ds = iFacede.InsertUpdateAppPreference(Globalized.ObjDbName, objInsert);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    System.Media.SystemSounds.Beep.Play();
                    lblErrorMsg.Visibility = Visibility.Hidden;
                    Globalized.SetMsg("Setting Saved successfully.", MsgType.Info);
                    loadData();
                    //    ModernWindow Obj = (ModernWindow)Application.Current.MainWindow;

                    //    Obj.ContentSource = new Uri("/Pages/Setting/Setting.xaml", UriKind.Relative);
                }
            }
            else
            {
                throw new ApplicationException(failures.First().ErrorMessage);
            }
        }
 internal dsGeneral.dtAppPreferenceDataTable GetAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
 {
     dsGeneral.dtAppPreferenceDataTable dt = objDALGeneral.GetAppPreference(objDBNames, objPreference);
     return(dt);
 }
Example #12
0
        public dsGeneral.dtAppPreferenceDataTable GetAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
        {
            dsGeneral ds       = new dsGeneral();
            DataSet   dsreturn = objDatabase.GetDataSet(objDBNames, objPreference, "xmlGetAppPreference", (DataSet)ds, "dtAppPreference");

            dsGeneral.dtAppPreferenceDataTable retdt = ((dsGeneral)dsreturn).dtAppPreference;
            return(retdt);
        }
Example #13
0
        public DataSet InsertUpdateAppPreference(dhDBnames objDBNames, dhAppPreference objPreference)
        {
            DataSet dsreturn = objDatabase.GetDataSet(objDBNames, objPreference, "xmlInsertUpdateAppPreference");

            return(dsreturn);
        }