private void BtnDeleteProc_Click(object sender, RoutedEventArgs e) { try { MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure?", "Delete Confirmation", System.Windows.MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { if (ObjToEditPro != null) { dhDocProcedures obj = MyViewModel.db.DocProcedures.Find(ObjToEditPro.IDocProceduresId); if (obj != null) { obj.BIsActive = false; MyViewModel.db.SaveChanges(); MyViewModel.ObjNewDoctor.DocProcedures.Remove(ObjToEditPro); this.DocProcedures.ItemsSource = this.MyViewModel.ObjNewDoctor.DocProcedures; } else { MyViewModel.ObjNewDoctor.DocProcedures.Remove(ObjToEditPro); this.DocProcedures.ItemsSource = this.MyViewModel.ObjNewDoctor.DocProcedures; } } MyViewModel.ObjNewDoctor.DocProcedures = MyViewModel.GetDocProcedures(); Globalized.SetMsg("DOC04", DataHolders.MsgType.Info); Globalized.ShowMsg(lblErrorMsg); } } catch (Exception ex) { // throw; } }
private void InsertRecord() { dhItems objInsert = new dhItems(); objInsert = (dhItems)this.ItemGrid_.DataContext; DataSet ds = iFacedeLayer.iFacede.InsertUpdateItem(Globalized.ObjDbName, objInsert); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["iItemID"].ToString() != "-1") { if (objInsert.IUpdate == 1) { Globalized.SetMsg("I02", DataHolders.MsgType.Info); } else { Globalized.SetMsg("I01", DataHolders.MsgType.Info); objInsert.IUpdate = 1; } AddItemViewModel ObjSetToEdit = new AddItemViewModel(objInsert); Globalized.LoadThisObject(ObjSetToEdit, "Edit Item '" + objInsert.VItemName + "'", Globalized.AppModuleList.Where(xx => xx.VModuleName == "Store").FirstOrDefault().VShortDescription); } else{ Globalized.SetMsg("I013", MsgType.Error); Globalized.ShowMsg(lblErrorMsg); } } }
//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); }
private void InsertUpdateAccount() { dhAccount objInsert = new dhAccount(); objInsert = (dhAccount)this.AccountDt.DataContext; dhAccountValidator validator = new dhAccountValidator(); FluentValidation.Results.ValidationResult results = validator.Validate(objInsert); bool validationSucceeded = results.IsValid; IList <ValidationFailure> failures = results.Errors; if (validationSucceeded) { if (this.vAccountType.SelectedValue != null) { objInsert.IFinaceType = Convert.ToInt32(this.vAccountType.SelectedValue.ToString()); } else { throw new ApplicationException("Please Select Account Type."); } DataSet ds = iFacede.InsertUpdateAccount(Globalized.ObjDbName, objInsert); if (ds.Tables[0].Rows.Count > 0) { if (objInsert.IUpdate == 1) { string msg = "Account '" + objInsert.AccountName + "' information is updated successfully."; Globalized.setException(msg, lblErrorMsg, DataHolders.MsgType.Info); //Globalized.SetMsg(msg, DataHolders.MsgType.Info); //Globalized.ShowMsg(lblErrorMsg); } else { System.Media.SystemSounds.Beep.Play(); lblErrorMsg.Visibility = Visibility.Hidden; Globalized.SetMsg("New Acount '" + objInsert.AccountName + "' is added successfully.", DataHolders.MsgType.Info); objTodisplay.IUpdate = 1; this.DataContext = objTodisplay; Globalized.ShowMsg(lblErrorMsg); } } Globalized.AccountListOptimizated(); } else { throw new ApplicationException(failures.First().ErrorMessage); } }
private void SaveAppointment(object sender, RoutedEventArgs e) { try { blAppointment objBlAppointment = new blAppointment(); dhAppointment ObjNewAppointment = (dhAppointment)this.AppointmentInfo.DataContext; // cehck for patient dhPatient ObjPatient = (dhPatient)this.PatientInformationGrid.DataContext; // doctor long iDocId = ((dhDoctorView)this.DoctorInformationGrid.DataContext).IDocid; dhDoctors objDoc = MyViewModel.db.Doctors.AsNoTracking().Where(x => x.IDocid == iDocId && x.BActive == true).FirstOrDefault(); if (objDoc == null) { return; } if (ObjPatient.iPatid == 0 || ObjPatient.iPatid < 0) { BlPatient objBl = new BlPatient(); objBl.AddNewPatient(ObjPatient); // need to save the patient first //MyViewModel.db.Patients.Add(ObjPatient); //MyViewModel.db.SaveChanges(); // set for patatient id ObjNewAppointment.IPatid = ObjPatient.iPatid; } // check for doctors if (ObjNewAppointment != null) { Dictionary <long, string> objDic = objBlAppointment.GetNextToken(objDoc, ObjNewAppointment); ObjNewAppointment.FormatedTokenNumber = objDic.First().Value; ObjNewAppointment.IToken_Number = objDic.First().Key; MyViewModel.db.Appointments.Add(ObjNewAppointment); MyViewModel.db.SaveChanges(); } this.AppointmentInfo.DataContext = ObjNewAppointment; Globalized.SetMsg("AOC01", DataHolders.MsgType.Info); Globalized.ShowMsg(lblErrorMsg); } catch (Exception ex) { Globalized.SetMsg(ex.Message, MsgType.Error); Globalized.ShowMsg(lblErrorMsg); } }
private void LoadData() { dhAccount objFinaceType = new dhAccount(); dsGeneral.dtPosFinaceTypeDataTable dtF = iFacede.GetFinaceType(Globalized.ObjDbName, objFinaceType); objTodisplay.FinanceTypeList = ReflectionUtility.DataTableToObservableCollection <dhFinanceType>(dtF); this.vAccountType.ItemsSource = objTodisplay.FinanceTypeList; this.vAccountType.DisplayMemberPath = "VFinaceType"; this.vAccountType.SelectedValuePath = "IFinaceType"; this.AccountDt.DataContext = this.objTodisplay; this.vAccountType.SelectedValue = this.objTodisplay.IFinaceType; if (objTodisplay.BEditable == false) { //accountNameTextBox.IsEnabled = false; //vAccountNoTextBox.IsEnabled = false; //vAccountDescTextBox.IsEnabled = false; //vAccountCommentsTextBox.IsEnabled = false; //vAccountType.IsEnabled = false; //bNominalCheckBox.IsEnabled = false; AccountDt.IsEnabled = false; this.btnSaveAcc.IsEnabled = false; Globalized.SetMsg("This is non-editable account.", MsgType.Info); Globalized.ShowMsg(lblErrorMsg); } else { AccountDt.IsEnabled = true; } if (objTodisplay.IUpdate > 0) { this.vAccountNoTextBox.IsEnabled = false; // this.vAccountNoTextBox.Background = new SolidColorBrush(Colors.Gray); } }
private void Button_Click(object sender, RoutedEventArgs e) { try { dhEmployee objEmployee = new dhEmployee(); objEmployee = (dhEmployee)EmpInfo.DataContext; objEmployee.VMartialStatus = VMartialStatus.SelectedValue.ToString(); int IIEmpid; if (cmbIEmpTypeId.SelectedValue != null) { int.TryParse(cmbIEmpTypeId.SelectedValue.ToString(), out IIEmpid); objEmployee.IEmpTypeId = IIEmpid; } else { objEmployee.IEmpTypeId = 1; objEmployee.IEmpTypeId = 1; } // check for existing Name dhEmployeeValidator validator = new dhEmployeeValidator(); FluentValidation.Results.ValidationResult results = validator.Validate(objEmployee); bool validationSucceeded = results.IsValid; IList <ValidationFailure> failures = results.Errors; if (validationSucceeded) { dsGeneral.dtEmployeeDataTable dtEmployee = iFacede.GetEmployee(Globalized.ObjDbName, new dhEmployee()); ObservableCollection <dhEmployee> listItem = ReflectionUtility.DataTableToObservableCollection <dhEmployee>(dtEmployee); string bFound = null; //if ((this.vEmployeeNameTextBox.Text!= "") && (item.VEmployeeName != "")) { } //foreach (dhEmployee item in ListAccounts) //{ // string[] words = item.VEmployeeName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // string[] filter = objEmployee.VEmployeeName.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // if ((objEmployee.IEmployeeID != null) && (item.IEmployeeID == objEmployee.IEmployeeID)) // { // continue; // } // bFound = words.Where(x => filter.Contains(x.ToLower())).FirstOrDefault(); // if (bFound != null) // { // break; // } //} //if (bFound != null) //{ // if (!blUtil.OverrideInformation(objEmployee.VEmployeeName, bFound)) // { // this.vEmployeeNameTextBox.SelectAll(); // this.vEmployeeNameTextBox.Focus(); // return; // } //} //if (iSaleManIDComboBox.SelectedValue != null) //{ // objEmployee.ISaleManID = Convert.ToInt32(iSaleManIDComboBox.SelectedValue.ToString()); //} // objEmployee.VCity = VMartialStatus.SelectedValue.ToString(); // objEmployee.VEmployeeadress = objEmployee.VMarket + " , " + objEmployee.VArea + " , " + objEmployee.VDistrict + " , " + objEmployee.VCity; //lblErrorMsg.Visibility = Visibility.Hidden; DataSet dsr = iFacede.InsertUpdateEmployee(Globalized.ObjDbName, objEmployee); if (dsr.Tables[0].Rows.Count > 0) { objEmployee.IEmpid = Convert.ToInt32(dsr.Tables[0].Rows[0][0].ToString()); } if (objEmployee.IUpdate == 1) { //lblErrorMsg.Visibility = Visibility.Visible; //lblErrorMsg.Foreground = Brushes.Green; //lblErrorMsg.Content = "Employee ' " + objEmployee.VEmployeeName + " ' Information is Updated Successfully"; Globalized.SetMsg("Employee ' " + objEmployee.VEmpfName + " ' Information is Updated Successfully", DataHolders.MsgType.Info); // Globalized.ShowMsg(lblErrorMsg); GlobalObjEmployee = objEmployee; // We need to get data from database to bind it back LoadData(); // LoadData(); } else { Globalized.SetMsg("Employee ' " + objEmployee.VEmpfName + " ' Information is Saved Successfully", DataHolders.MsgType.Info); objEmployee.IUpdate = 1; GlobalObjEmployee = objEmployee; // We need to get data from database to bind it back LoadData(); // ModernWindow Obj = (ModernWindow)Application.Current.MainWindow; // GlobalObjEmployee = null; // Obj.ContentSource = new Uri("/Pages/emp/listEmp.xaml", UriKind.Relative); } } else { System.Media.SystemSounds.Beep.Play(); lblErrorMsg.Visibility = Visibility.Visible; lblErrorMsg.Foreground = Brushes.Red; lblErrorMsg.Content = failures.First().ErrorMessage; } //Globalized.ShowMsg(lblErrorMsg); } catch (Exception ex) { Globalized.setException(ex, lblErrorMsg, MsgType.Error); } }
private void BtnSaveDoctor_Click(object sender, RoutedEventArgs e) { try { if (objNewDoctor.IUpdate == 0 || objNewDoctor.IUpdate == null) { if (objNewDoctor.TokenStart == "" || objNewDoctor.TokenStart == null) { objNewDoctor.TokenStart = objNewDoctor.VfName.Substring(0, 2).ToUpper(); } MyViewModel.db.Doctors.Add(objNewDoctor); MyViewModel.db.SaveChanges();; // for investigations foreach (DocInvestigations item in objNewDoctor.DocInvestigations) { item.IDocid = objNewDoctor.IDocid; item.BIsActive = true; MyViewModel.db.DocInvestigations.Add(item); } // for doc procedures dhAccount objAccount = MyViewModel.InsertUpdateAccount(objNewDoctor); MyViewModel.db.Accounts.Add(objAccount); // need to set for doc proc this.AddEditDocProcedures(); Globalized.SetMsg("DOC01", DataHolders.MsgType.Info); } // if update flag is set if (objNewDoctor.IUpdate == 1) { // dhDoctors temp = MyViewModel.db.Doctors.Find(objNewDoctor.IDocid); objNewDoctor = (dhDoctors)this.NewDoctorGrid.DataContext; if (objNewDoctor.TokenStart == "" || objNewDoctor.TokenStart == null) { objNewDoctor.TokenStart = objNewDoctor.VfName.Substring(0, 2).ToUpper(); } MyViewModel.db.Doctors.Attach(objNewDoctor); //.State = EntityState.Added; MyViewModel.db.Entry(objNewDoctor).State = EntityState.Modified; dhAccount objAccount = MyViewModel.InsertUpdateAccount(objNewDoctor); // MyViewModel.db.Accounts.Attach(objAccount); MyViewModel.db.Entry(objAccount).State = EntityState.Modified; // check existing investigation ObservableCollection <DocInvestigations> crntInv = MyViewModel.db.DocInvestigations.Where(x => x.IDocid == objNewDoctor.IDocid && x.BIsActive == true).ToObservableCollection(); foreach (DocInvestigations item in objNewDoctor.DocInvestigations) { item.IDocid = objNewDoctor.IDocid; // make this investigation active item.BIsActive = true; if (crntInv.Select(x => x.IDocInvestigationsId == item.IDocInvestigationsId).FirstOrDefault() == false) { MyViewModel.db.DocInvestigations.Add(item); } else { DocInvestigations tempDoinv = this.MyViewModel.db.DocInvestigations.Find(item.IDocInvestigationsId); if (tempDoinv != null) { tempDoinv = item; } } // if(crntInv.fi) } // need to set for doc proc this.AddEditDocProcedures(); Globalized.SetMsg("DOC02", DataHolders.MsgType.Info); } // final save and update model objNewDoctor.IUpdate = 1; // now it will ebe update object MyViewModel.db.SaveChanges(); // set Doctor MyViewModel.ObjNewDoctor = objNewDoctor; MyViewModel.ObjNewDoctor.DocInvestigations = MyViewModel.GetActiveDocInvestigations(); MyViewModel.DoctorAccount = MyViewModel.GetDocAccount(); this.AccountInfo.DataContext = MyViewModel.DoctorAccount; Globalized.ShowMsg(lblErrorMsg); } catch (Exception ex) { Globalized.SetMsg(ex.Message, MsgType.Error); Globalized.ShowMsg(lblErrorMsg); } // this.DataContext }
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); } }
private void SaveTheParty(object sender, RoutedEventArgs e) { try { dhParty objParty = new dhParty(); objParty = (dhParty)grid1.DataContext; objParty.VCity = vCityList.SelectedValue != null?this.vCityList.SelectedValue.ToString() : null; dsGeneral.dtPosPartyDataTable dtParty = iFacede.GetParty(Globalized.ObjDbName, new dhParty()); ObservableCollection <dhParty> listItem = BL.ReflectionUtility.DataTableToObservableCollection <dhParty>(dtParty); string bFound = null; foreach (dhParty item in listItem) { string[] words = item.VPartyName.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string[] filter = objParty.VPartyName.ToLower().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if ((objParty.IPartyID != null) && (item.IPartyID == objParty.IPartyID)) { continue; } bFound = words.Where(x => filter.Contains(x.ToLower())).FirstOrDefault(); if (bFound != null) { break; } } if (bFound != null) { if (!blUtil.OverrideInformation(objParty.VPartyName, bFound)) { this.vPartyNameTextBox.SelectAll(); this.vPartyNameTextBox.Focus(); return; } } objParty.VPartyadress = objParty.VMarket + " , " + objParty.VArea + " , " + objParty.VDistrict + " , " + objParty.VCity; lblErrorMsg.Visibility = Visibility.Hidden; DataSet dsr = iFacede.InsertUpdateParty(Globalized.ObjDbName, objParty); if (dsr.Tables.Count > 0) { DataTable dtb = dsr.Tables[0]; if (dtb.Rows.Count > 0) { objParty = BL.ReflectionUtility.DataTableToObservableCollection <dhParty>(dtb).FirstOrDefault(); } } if (((dhParty)grid1.DataContext).IUpdate == 1) { Globalized.SetMsg("P02", DataHolders.MsgType.Info); } else { Globalized.SetMsg("P01", DataHolders.MsgType.Info); objParty.IUpdate = 1; AddPartyViewModel ObjSetToEdit = new AddPartyViewModel(objParty); Globalized.LoadThisObject(ObjSetToEdit, "Edit Party '" + objParty.VPartyName + "'", Globalized.AppModuleList.Where(xx => xx.VDisplayName == "Party").FirstOrDefault().VShortDescription); } Globalized.ShowMsg(lblErrorMsg); } catch (Exception ex) { Globalized.GlobalMsg = null; Globalized.SetMsg(ex.Message, MsgType.Error); Globalized.ShowMsg(lblErrorMsg); } }