public IEnumerable <ModelRecord> GetBookingData(string Roomid, string sdate, string edate, string userid) { string sql = string.Format(@" select t.roomid, t.RECORDID, t.starttime, t.endtime, decode(lower(t.applierid),'{3}','APPL',t.booktype) booktype, t.updatet, t.applierid, t.applier, t.applierext, '' as dateday from MBS_RECORD t where t.starttime between to_date('{0}', 'yyyy/mm/dd') and to_date('{1}', 'yyyy/mm/dd')+1 and t.roomid in ('{2}') ", sdate, edate, Roomid, userid); DataSet ds = DALService.ExecuteDataSet(sql); IEnumerable <ModelRecord> ret = GetBRecordList(ds.Tables[0]); ret = ret.Concat( GenRangeSysBookRecord(new List <string> { Roomid }, sdate, edate)); ds.Dispose(); return(ret); }
public IEnumerable <ModelMR> GetMeetingRoom(string site, string plant, string floor) { string sSite = site == "" || site == null ? " 1=1 " : " b.site = '" + site + "'"; string sPlant = plant == "" || plant == null ? " 1=1 " : " b.plant = '" + plant + "'"; string sFloor = floor == "" || floor == null ? " 1=1 " : " b.floor = '" + floor + "'"; IEnumerable <ModelMR> ret = null; string sql = string.Format(@"select a.roomid, a.roomname, a.roomabbr, a.siteid, b.site, b.plant, b.floor, a.eqipment, a.ext, a.cnpc, a.ip, a.accessright, a.postperiod, a.imgpath, a.minp, a.maxp from MBS_ROOM a, mbs_area b where a.siteid = b.siteid and {0} and {1} and {2} order by roomname ", sSite, sPlant, sFloor); DataSet ds = DALService.ExecuteDataSet(sql); return(GetMRList(ds)); }
public ModelMR GetMeetingRoomByID(string id) { string sql = string.Format(@"select a.roomid, a.roomname, a.roomabbr, a.siteid, b.site, b.plant, b.floor, a.eqipment, a.ext, a.cnpc, a.ip, a.accessright, a.postperiod, a.imgpath, a.minp, a.maxp from MBS_ROOM a, mbs_area b where a.siteid = b.siteid and roomid ='{0}' order by roomname", id); DataSet ds = DALService.ExecuteDataSet(sql); return(ds.Tables[0].Rows.Count == 1 ? GetMRList(ds).First() : null); //return GetMRList(ds); }
public void MustGetEntity() { var _savedPage = DALService <Page> .Get(id).Result; Assert.IsNotNull(_savedPage); Assert.AreEqual(_name, _savedPage.Name); Assert.AreEqual(_content, _savedPage.Content); }
private string GetSiteid(string site, string plant, string floor) { string sql = string.Format(@" select siteid from MBS_AREA t where t.site = '{0}' and t.plant = '{1}' and t.floor = '{2}' ", site, plant, floor); return(DALService.ExecuteDataSet(sql).Tables[0].Rows[0][0].ToString()); }
static void Main(string[] args) { CFConfig.Default .RegisterContainer() .RegisterDataMapping() .RegisterEFRepository(); Console.WriteLine("1. 运行Data示例"); Console.WriteLine("2. 运行Domain示例"); Console.WriteLine("3. 运行CQRS示例"); Console.WriteLine("4. 运行Actor示例"); Console.WriteLine("请输入序号:"); ISampleService service = null; char key = Console.ReadKey(true).KeyChar; if (key == '1') { service = new DALService(); } else if (key == '2') { service = new DDDService(); } else if (key == '3') { CFConfig.Default .RegisterMessageDispatcher(); service = CFAspect.Resolve <ISampleService>(); } else if (key == '4') { CFConfig.Default .RegisterMessageBroker("127.0.0.1") .RegisterMessageDispatcher("127.0.0.1"); service = CFAspect.Resolve <ISampleService>(); } if (service != null) { try { Console.WriteLine(service.GetType().Name + " Running..."); long orderID1 = service.CreateUser("张三"); var order1 = service.FindUser("张三"); long orderID2 = service.CreateUser("李四"); var order2 = service.FindUser("李四"); long orderID3 = service.CreateUser("王五"); var order3 = service.FindUser("王五"); } catch (Exception ex) { Console.WriteLine("异常:" + ex.Message); } } Console.ReadKey(); }
public IEnumerable <ModelRecord> GetBookingData(string sdate, string userid, List <string> roomid) { List <string> sqls = new List <string>(); DateTime dt1 = DateTime.Parse(sdate); string dayofWeek = ((int)dt1.DayOfWeek).ToString(); // 一般預約 sqls.Add(string.Format(@" select t.roomid, t.RECORDID, t.starttime, t.endtime, decode(lower(t.applierid),'{2}','APPL',t.booktype) booktype, t.updatet, t.applierid, t.applier, t.applierext, '' as dateday from MBS_RECORD t where t.starttime <= to_date('{0}', 'yyyy/mm/dd') + 1 and t.endtime >= to_date('{0}', 'yyyy/mm/dd') and t.roomid in ('{1}') ", sdate, string.Join("','", roomid.ToArray()), userid)); // 系統預約 // sqls.Add(string.Format(@" // select t.roomid, // t.sid as RECORDID, // to_date('{0} ' || SUBSTR(starttime, 1, 2) || ':' || // SUBSTR(starttime, 3, 2) || ':' || '00', // 'yyyy/mm/dd hh24:mi:ss') as starttime, // to_date('{0} ' || SUBSTR(endtime, 1, 2) || ':' || // SUBSTR(endtime, 3, 2) || ':' || '00', // 'yyyy/mm/dd hh24:mi:ss') as endtime, // sysdate as UPDATET, // 'SYSL' as booktype, // 'SYSTEM' as APPLIER, // 'SYSTEM' as applierid, // '' as applierext, // dateday // from MBS_LOCKROOM t // where t.roomid in ('{1}') // and t.dateday = '{2}' // ", sdate, string.Join("','", roomid.ToArray()), dayofWeek)); DataSet ds = DALService.ExecuteBatchQuery(sqls.ToArray()); IEnumerable <ModelRecord> ret = GetBRecordList(ds.Tables[0]); ret = ret.Concat( GenRangeSysBookRecord(roomid, sdate, sdate)); ds.Dispose(); return(ret); }
public void MustDeleteEntity() { var _page = DALService <Page> .Get(id).Result; var deleteRes = DALService <Page> .Delete(_page).Result; var _deletedPage = DALService <Page> .Get(id).Result; Assert.IsTrue(deleteRes); Assert.IsNull(_deletedPage); }
public void MustInsertEntity() { var _page = new Page() { Content = _content, Name = _name }; var res = DALService <Page> .Add(_page).Result; Assert.IsNotNull(res); Assert.IsNotEmpty(res.ID.ToString()); }
// 操作 public int DeleteBookingData(string recordid, string userid) { string sql = string.Format(@" delete MBS_RECORD t where recordid = '{0}' and applierid = '{1}' and starttime > sysdate ", recordid, userid); return(DALService.ExecuteNonQuery(sql)); }
private IEnumerable <ModelRecord> GenRangeSysBookRecord(List <string> roomid, string sdate, string edate) { List <ModelRecord> ret = new List <ModelRecord>(); string sql = string.Format(@" select t.roomid, t.sid as RECORDID, to_date('{0} ' || SUBSTR(starttime, 1, 2) || ':' || SUBSTR(starttime, 3, 2) || ':' || '00', 'yyyy/mm/dd hh24:mi:ss') as starttime, to_date('{0} ' || SUBSTR(endtime, 1, 2) || ':' || SUBSTR(endtime, 3, 2) || ':' || '00', 'yyyy/mm/dd hh24:mi:ss') as endtime, sysdate as UPDATET, 'SYSL' as booktype, 'SYSTEM' as APPLIER, 'SYSTEM' as applierid, '' as applierext, dateday from MBS_LOCKROOM t where t.roomid in ('{1}') ", sdate, string.Join("','", roomid.ToArray())); IEnumerable <ModelRecord> ret2 = GetBRecordList(DALService.ExecuteDataSet(sql).Tables[0]); DateTime dts1 = DateTime.Parse(sdate); DateTime dts = DateTime.Parse(sdate); DateTime dte = DateTime.Parse(edate); int i = 0; while (DateTime.Compare(dte, dts) >= 0) { IEnumerable <ModelRecord> ret3 = ret2 .Where(x => x.DATEDAY == ((int)dts.DayOfWeek).ToString()) .Select(x => x); if (ret3.Count() > 0) { ret3 = ret3.Select(x => { x.STARTTIME = DateTime.Parse(x.STARTTIME).AddDays(i).ToString("yyyy/MM/dd HH:mm:ss"); x.ENDTIME = DateTime.Parse(x.ENDTIME).AddDays(i).ToString("yyyy/MM/dd HH:mm:ss"); return(x); }); ret.AddRange(ret3.ToList()); } i = i + 1; dts = dts1.AddDays(i); } return(ret); }
public void MustUpdateEntity() { const string newContent = "<i>updated content</i>"; var _pageToUpdate = DALService <Page> .Get(id).Result; _pageToUpdate.Content = newContent; var updateRes = DALService <Page> .Update(_pageToUpdate).Result; Assert.IsTrue(updateRes); var _pageAfterUpdate = DALService <Page> .Get(id).Result; Assert.AreEqual(newContent, _pageAfterUpdate.Content); Assert.AreEqual(_pageToUpdate.Name, _pageAfterUpdate.Name); Assert.AreEqual(_pageToUpdate.ID, _pageAfterUpdate.ID); }
public bool UpdateMRRoom(ModelMR mr) { clsSQLBuilder cls = new clsSQLBuilder(); cls.AddField("ACCESSRIGHT", clsSQLBuilder.FieldType.FD_STRING, mr.ACCESSRIGHT, true); cls.AddField("CNPC", clsSQLBuilder.FieldType.FD_STRING, mr.CNPC, true); cls.AddField("EQIPMENT", clsSQLBuilder.FieldType.FD_STRING, mr.EQIPMENT, true); cls.AddField("EXT", clsSQLBuilder.FieldType.FD_STRING, mr.EXT, true); // cls.AddField("FLOOR", clsSQLBuilder.FieldType.FD_STRING, mr.FLOOR, true); cls.AddField("IMGPATH", clsSQLBuilder.FieldType.FD_STRING, mr.IMGPATH, true); cls.AddField("IP", clsSQLBuilder.FieldType.FD_STRING, mr.IP, true); cls.AddField("MAXP", clsSQLBuilder.FieldType.FD_NUMBER, mr.MAXP.ToString(), true); cls.AddField("MINP", clsSQLBuilder.FieldType.FD_NUMBER, mr.MINP.ToString(), true); cls.AddField("POSTPERIOD", clsSQLBuilder.FieldType.FD_NUMBER, mr.POSTPERIOD.ToString(), true); cls.AddField("PLANT", clsSQLBuilder.FieldType.FD_STRING, mr.PLANT.ToString(), true); cls.AddField("ROOMABBR", clsSQLBuilder.FieldType.FD_STRING, mr.ROOMABBR.ToString(), true); cls.AddField("ROOMID", clsSQLBuilder.FieldType.FD_STRING, mr.ROOMID.ToString(), false); cls.AddField("ROOMNAME", clsSQLBuilder.FieldType.FD_STRING, mr.ROOMNAME.ToString(), true); cls.AddField("SITE", clsSQLBuilder.FieldType.FD_STRING, mr.SITE.ToString(), true); cls.AddField("SITEID", clsSQLBuilder.FieldType.FD_STRING, GetSiteid(mr.SITE, mr.PLANT, mr.FLOOR), true); string sqls = string.Format(@"MERGE INTO {0} USING DUAL ON (ROOMID = '{1}') WHEN MATCHED THEN UPDATE SET {2} WHEN NOT MATCHED THEN INSERT {3}" , "MBS_ROOM " , mr.ROOMID , cls.GetString_Update() , cls.GetString_Insert() ); DALService.ExecuteNonQuery(sqls); return(true); }
public void BookingEvent(ModelRecord[] objM) { // 更新Room List <string> sqls = new List <string>(); foreach (var ob in objM) { clsSQLBuilder cls = new clsSQLBuilder(); cls.AddField("RECORDID", clsSQLBuilder.FieldType.FD_STRING, ob.RECORDID, false); cls.AddField("ROOMID", clsSQLBuilder.FieldType.FD_STRING, ob.ROOMID, false); cls.AddField("STARTTIME", clsSQLBuilder.FieldType.FD_DATETIME, ob.STARTTIME, false); cls.AddField("ENDTIME", clsSQLBuilder.FieldType.FD_DATETIME, ob.ENDTIME, false); cls.AddField("BOOKTYPE", clsSQLBuilder.FieldType.FD_STRING, ob.BOOKTYPE, false); cls.AddField("UPDATET", clsSQLBuilder.FieldType.FD_DATE, ob.UPDATET, false); cls.AddField("APPLIER", clsSQLBuilder.FieldType.FD_STRING, ob.APPLIER, false); cls.AddField("APPLIEREXT", clsSQLBuilder.FieldType.FD_STRING, ob.APPLIEREXT, false); cls.AddField("APPLIERID", clsSQLBuilder.FieldType.FD_STRING, ob.APPLIERID, false); cls.AddField("RECORDID", clsSQLBuilder.FieldType.FD_STRING, ob.RECORDID, false); sqls.Add(string.Format(@" insert into MBS_RECORD {0}", cls.GetString_Insert())); } DALService.ExecuteBatchNonQuery(sqls.ToArray()); }
public void MustGetManyEntities() { //deleting the page created on SetUp DALService <Page> .Delete(new Page() { ID = id }); int i = 5; while (i > 0) { var res = DALService <Page> .Add(new Page() { Content = $"{_content}{i}", Name = $"{_name}{i}" }).Result; --i; } var pages = DALService <Page> .GetMany(p => p.Name.Contains(_name) && p.Content.Contains(_content)); Assert.IsTrue(pages.Result.Count() == 5); }
private void ConfigureDatabase() { DALService.InitDatabase(); }
static void Main(string[] args) { int menuChoise = 0; DALService dalService = new DALService(); Console.WriteLine("-----LOGIN-----"); Console.WriteLine("1. Sign in"); Console.WriteLine("2. Sign up"); Console.WriteLine("3. Exit"); Console.WriteLine("Enter choise: "); try { menuChoise = int.Parse(Console.ReadLine()); } catch (ArgumentNullException e) { Console.WriteLine(e.Message); } switch (menuChoise) { case 1: { string login; string password; Account account = new Account(); Console.Clear(); Console.WriteLine("Enter login: "******"Enter password: "******"-----MENU-----"); Console.WriteLine("1. Search plate"); Console.WriteLine("2. Change login"); Console.WriteLine("3. Change password"); Console.WriteLine("4. Exit"); Console.WriteLine("Enter choise: "); int choiseMenu = int.Parse(Console.ReadLine()); switch (choiseMenu) { case 1: { Console.Clear(); Console.WriteLine("-----SEARCH PLATE-----"); Console.WriteLine("1. By name"); Console.WriteLine("2. By band "); Console.WriteLine("3. By genre"); Console.WriteLine("4. Exit"); Console.WriteLine("Enter choise: "); choiseMenu = int.Parse(Console.ReadLine()); switch (choiseMenu) { case 1: { string plateName; Console.Clear(); Console.WriteLine("Enter name of plate: "); plateName = Console.ReadLine(); IQueryable <Plate> plates = dalService.FindPlateByName(plateName); if (plates == null) { break; } foreach (var p in plates) { string buyChoise; Console.WriteLine("Name: " + p.Name); Console.WriteLine("Band name: " + p.Band.Name); Console.WriteLine("Price: " + p.SalePrice); Console.WriteLine(); Console.WriteLine("Do you want to buy the plate?"); Console.WriteLine("Enter yes ot no: "); buyChoise = Console.ReadLine(); if (buyChoise == "yes") { dalService.SellPlate(p.Id, account.Id); } } break; } case 2: { string plateBand; Console.Clear(); Console.WriteLine("Enter name of band: "); plateBand = Console.ReadLine(); List <Plate> plates = (List <Plate>)dalService.FindPlateByBand(plateBand); if (plates == null) { break; } foreach (var p in plates) { string buyChoise; Console.WriteLine("Name: " + p.Name); Console.WriteLine("Band name: " + p.Band.Name); Console.WriteLine("Price: " + p.SalePrice); Console.WriteLine(); Console.WriteLine("Do you want to buy the plate?"); Console.WriteLine("Enter yes ot no: "); buyChoise = Console.ReadLine(); if (buyChoise == "yes") { dalService.SellPlate(p.Id, account.Id); } } break; } case 3: { string plateGenre; Console.Clear(); Console.WriteLine("Enter name of genre: "); plateGenre = Console.ReadLine(); List <Plate> plates = (List <Plate>)dalService.FindPlateByGenre(plateGenre); if (plates == null) { break; } foreach (var p in plates) { string buyChoise; Console.WriteLine("Name: " + p.Name); Console.WriteLine("Band name: " + p.Band.Name); Console.WriteLine("Price: " + p.SalePrice); Console.WriteLine(); Console.WriteLine("Do you want to buy the plate?"); Console.WriteLine("Enter yes ot no: "); buyChoise = Console.ReadLine(); if (buyChoise == "yes") { dalService.SellPlate(p.Id, account.Id); } } break; } } break; } case 2: { Console.Clear(); string newLogin; Console.WriteLine("Enter new login: "******"Enter new password: "******"Goodbye!"); Console.ReadKey(); break; } } break; } case 2: { break; } case 3: { break; } default: { break; } } }
public testSingleton() { CategoryRepository service = DALService.GetService <CategoryRepository>(); Console.WriteLine("building testsingleton"); }
public string BookRoomEvent([FromBody] ModelRecord recordobj) { string ret = "成功預約"; DateTime out1; try { APIHelper ws = new APIHelper(); UserInfo vUserInfo = new UserInfo(); string roomid = recordobj.ROOMID; ModelMR mr = ws.GetMeetingRoomByID(roomid); if (mr == null) { throw new Exception("找不到會議室"); } DateTime sdt = DateTime.Parse(recordobj.STARTTIME); DateTime edt = DateTime.Parse(recordobj.ENDTIME); // .ToString("yyyy/MM/dd HH:mm:ss"), List <int> minuInt = new List <int> { 0, 15, 30, 45 }; if (!minuInt.Contains(sdt.Minute) || !minuInt.Contains(edt.Minute)) { throw new Exception("時間格式錯誤"); } TimeSpan ts = edt.Subtract(sdt); if (ts.TotalSeconds == 0) { throw new Exception("起始結束時間不可一樣"); } if (DateTime.Compare(DateTime.Today, sdt) > 0) { throw new Exception("預約日期不可小於今日"); } // 檢查預約天數 if (DateTime.Compare(sdt, DateTime.Today.AddDays(mr.POSTPERIOD)) > 0) { throw new Exception("預約日期不可大於 (" + mr.POSTPERIOD + ") 天"); } // 檢查會議室時間是否為系統預約 int dateday = (int)sdt.DayOfWeek; List <string> sqls = new List <string>(); #region 檢查 是否被預約 sqls.Add(string.Format(@" select * from MBS_RECORD t where t.roomid = '{0}' and( t.starttime between to_date('{1}', 'yyyy/mm/dd hh24:mi:ss') AND to_date('{2}', 'yyyy/mm/dd hh24:mi:ss') or t.endtime between to_date('{1}', 'yyyy/mm/dd hh24:mi:ss') AND to_date('{2}', 'yyyy/mm/dd hh24:mi:ss')) ", roomid, sdt.AddSeconds(1).ToString("yyyy/MM/dd HH:mm:ss"), edt.AddSeconds(-1).ToString("yyyy/MM/dd HH:mm:ss"))); #endregion #region 檢查系統預約 sql sqls.Add(string.Format(@"select a.dateday,a.starttime,a.endtime from MBS_LOCKROOM a where a.roomid = '{0}' and (a.starttime between '{2}' AND '{3}' or a.endtime between '{4}' AND '{5}') and a.dateday = '{1}' ", roomid , dateday.ToString(), sdt.ToString("HHmm"), edt.AddMinutes(-1).ToString("HHmm"), sdt.AddMinutes(1).ToString("HHmm"), edt.ToString("HHmm") )); #endregion DataSet ds = DALService.ExecuteBatchQuery(sqls.ToArray()); IEnumerable <DataRow> drow = ds.Tables[0].AsEnumerable(); if (drow.Count() > 0) { string sRepeat = string.Join("\n", drow.Select( x => x["applier"].ToString() + " From : " + x["starttime"].ToString() + " To :" + x["endtime"].ToString()).ToArray()); throw new Exception("重覆預約 \n" + sRepeat); } IEnumerable <DataRow> Srow = ds.Tables[1].AsEnumerable(); ds.Dispose(); if (Srow.Count() > 0) { string sRepeat = string.Join("\n", Srow.Select( x => Enum.GetName(typeof(DayOfWeek), int.Parse(x["dateday"].ToString())) + " : " + x["starttime"].ToString() + " To :" + x["endtime"].ToString() ).ToArray()); throw new Exception("此會議室已被系統預約 時間 \n" + sRepeat); } recordobj.RECORDID = Guid.NewGuid().ToString(); recordobj.BOOKTYPE = "USER"; recordobj.APPLIER = vUserInfo.CName; recordobj.APPLIEREXT = vUserInfo.Ext; recordobj.APPLIERID = vUserInfo.UserId; recordobj.UPDATET = "sysdate"; ws.BookingEvent(new [] { recordobj }); } catch (Exception ex) { ret = ex.Message; } //檢查預約事件 格式是否異常 return(ret); }
public ViewModel() { DALService = new DALService(); loginCommand = new DelegateCommand(Login); registrationCommand = new DelegateCommand(Registration); loginRegistrationShowCommand = new DelegateCommand(ShowLoginRegistrationForm, () => !Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password)); exitCommand = new DelegateCommand(Exit, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password)); addArtistCommand = new DelegateCommand(AddArtist, () => CurrentAccount.IsClient == false && Artist.Name != "" && !Artists.Any(a => a.Name == Artist.Name)); addGenreCommand = new DelegateCommand(AddGenre, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false); addPublisherCommand = new DelegateCommand(AddPublisher, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false); addRecordCommand = new DelegateCommand(AddRecord); editRecordCommand = new DelegateCommand(EditRecord, () => CurrentAccount.IsClient == false && SelectedRecord != null); removeRecordCommand = new DelegateCommand(RemoveRecord, () => SelectedRecord != null && CurrentAccount.IsClient == false); discardRecordCommand = new DelegateCommand(DiscardRecord, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false && SelectedRecord != null); sellRecordCommand = new DelegateCommand(Sell, () => CurrentAccount.IsClient == false && SelectedRecord != null && SelectedRecord.Name != "" && Date.Date == DateTime.Now.Date && Total > 0); setAsideCommand = new DelegateCommand(SetAside, () => Accounts.Contains(currentAccount) && CurrentAccount.IsClient == false && Client != null && Client.Email != "" && SelectedRecord != null && Date.Date >= DateTime.Now.Date); createDealCommand = new DelegateCommand(CreateDeal, () => CurrentAccount.IsClient == false); addRecordToDealCommand = new DelegateCommand(AddRecordToDeal, () => CurrentAccount.IsClient == false && Deal != null && SelectedRecord != null); searchCommand = new DelegateCommand(Search, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password) && !String.IsNullOrWhiteSpace(SearchBy) && (!String.IsNullOrWhiteSpace(SearchLine) || SearchBy == "All")); showCommand = new DelegateCommand(Show, () => Accounts.Any(a => a.Login == currentAccount.Login && a.Password == currentAccount.Password) && !String.IsNullOrWhiteSpace(TopFor)); searchByList.Add("All"); searchByList.Add("Name"); searchByList.Add(nameof(Artist)); searchByList.Add(nameof(Genre)); topForTheList.Add("Day"); topForTheList.Add("Week"); topForTheList.Add("Month"); topForTheList.Add("Year"); TopFor = "Day"; selectedRecord = new Record() { DateOfPublishing = DateTime.Now }; artist = new Artist(); genre = new Genre(); publisher = new Publisher(); deal = new Deal() { StartDate = DateTime.Now, EndDate = DateTime.Now }; currentAccount = new Account() { Login = "", Password = "", IsClient = true }; currentClient = new Client() { Account = currentAccount, Name = "", Surname = "", Phone = "", Email = "", Discount = 0 }; client = new Client() { Account = new Account() { Login = "", Password = "" }, Name = "", Surname = "", Phone = "", Email = "", Discount = 0 }; FillAccounts(); FillClients(); PropertyChanged += (sender, args) => { if (args.PropertyName == nameof(CurrentAccount)) { loginCommand.RaiseCanExecuteChanged(); registrationCommand.RaiseCanExecuteChanged(); loginRegistrationShowCommand.RaiseCanExecuteChanged(); exitCommand.RaiseCanExecuteChanged(); addArtistCommand.RaiseCanExecuteChanged(); addGenreCommand.RaiseCanExecuteChanged(); addPublisherCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); editRecordCommand.RaiseCanExecuteChanged(); removeRecordCommand.RaiseCanExecuteChanged(); sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); showCommand.RaiseCanExecuteChanged(); searchCommand.RaiseCanExecuteChanged(); createDealCommand.RaiseCanExecuteChanged(); discardRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(CurrentClient)) { loginCommand.RaiseCanExecuteChanged(); registrationCommand.RaiseCanExecuteChanged(); loginRegistrationShowCommand.RaiseCanExecuteChanged(); exitCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Artist)) { addArtistCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Genre)) { addGenreCommand.RaiseCanExecuteChanged(); addRecordCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Publisher)) { addRecordCommand.RaiseCanExecuteChanged(); addPublisherCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SelectedRecord)) { addRecordCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); editRecordCommand.RaiseCanExecuteChanged(); discardRecordCommand.RaiseCanExecuteChanged(); removeRecordCommand.RaiseCanExecuteChanged(); sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Deal)) { createDealCommand.RaiseCanExecuteChanged(); addRecordToDealCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Date)) { sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SearchBy)) { searchCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(SearchLine)) { searchCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(TopFor)) { showCommand.RaiseCanExecuteChanged(); } else if (args.PropertyName == nameof(Client)) { sellRecordCommand.RaiseCanExecuteChanged(); setAsideCommand.RaiseCanExecuteChanged(); CalculateTotal(); } else if (args.PropertyName == nameof(Total)) { sellRecordCommand.RaiseCanExecuteChanged(); } }; }