Example #1
0
 public void ReceiveMember(MessageMember m)
 {
     if (m.Message == "Add")
     {
         members.Add(new Member(m.FirstName, m.LastName, m.Email));
         add.Close();
         //Add new member and then save it to the data base
         members.Save();
         this.RaisePropertyChanged(() => members.Members);
     }
     else if (m.Message.Equals("Close"))
     {
         if (add != null)
         {
             add.Close();
         }
         else if (update != null)
         {
             update.Close();
         }
     }
     else if (m.Message.Equals("Update"))
     {
         members.Update(selected, m);
         update.Close();
         members.Save();
         this.RaisePropertyChanged(() => members.Members);
     }
 }
Example #2
0
        public Customer AddCustomer()
        {
            vm = new AddWindowViewModel
            {
                CancelCommand = new RelayCommand(o => window.Close()),
                OkCommand     = new RelayCommand(o => { window.DialogResult = true; window.Close(); })
            };

            window = new AddWindow
            {
                DataContext = vm
            };

            var result = window.ShowDialog() ?? false;

            return(!string.IsNullOrEmpty(vm.FirstName) || !string.IsNullOrEmpty(vm.LastName)
                ? result ? vm.Customer : null
                : null);
        }
Example #3
0
        private void saveNewTask(object parameter)
        {
            Tasks.Add(new Task {
                Title        = _addWindow.titleTB.Text, TaskDescription = _addWindow.descTB.Text,
                Periodicity  = (Periodicity)Enum.Parse(typeof(Periodicity), _addWindow.periodicityCB.Text),
                TaskCategory = (Category)Enum.Parse(typeof(Category), _addWindow.categoryCB.Text),
                TaskPriority = (Priority)Enum.Parse(typeof(Priority), _addWindow.priorityCB.Text)
            });

            _fileIOService.SaveData(Tasks);

            _addWindow.Close();
        }
        private void AddGoodsCommandEv(object parametr)
        {
            AddGoodsViewModel addGoodsViewModel = new AddGoodsViewModel(_mainDataContext);
            AddWindow         DialogWin         = new AddWindow();

            DialogWin.DataContext = addGoodsViewModel;
            if (addGoodsViewModel.CloseAct == null)
            {
                addGoodsViewModel.CloseAct = new Action(() => DialogWin.Close());
            }

            DialogWin.ShowDialog();
        }
        private void EditGoodsCommandEv(object parametr)
        {
            Goods goodsSel = parametr as Goods;
            EditeGoodsViewModel editGoodsViewModel = new EditeGoodsViewModel(goodsSel, _mainDataContext);
            AddWindow           DialogWin          = new AddWindow();

            DialogWin.DataContext = editGoodsViewModel;
            if (editGoodsViewModel.CloseAct == null)
            {
                editGoodsViewModel.CloseAct = new Action(() => DialogWin.Close());
            }

            DialogWin.ShowDialog();
        }
Example #6
0
 protected void UploadFile_Click(object sender, DirectEventArgs e)
 {
     try
     {
         string filename    = Path.GetFileName(UploadDoc.PostedFile.FileName);
         string contentType = UploadDoc.PostedFile.ContentType;
         using (Stream fs = UploadDoc.PostedFile.InputStream)
         {
             using (BinaryReader br = new BinaryReader(fs))
             {
                 byte[] bytes = br.ReadBytes((Int32)fs.Length);
                 using (MySqlConnection con = new MySqlConnection(MySqlString))
                 {
                     string query = "INSERT INTO pat_monthdoc(Month, Name, Content, Size, SaveDateTime, User) ";
                     query += "VALUES (@Month, @FileName, @Content, @FileSize, @SaveDateTime, @UserName)";
                     using (MySqlCommand cmd = new MySqlCommand(query))
                     {
                         cmd.Connection = con;
                         cmd.Parameters.AddWithValue("@Month", YearMonth.Text);
                         cmd.Parameters.AddWithValue("@FileName", DateTime.Now.ToString("yyyyMM_") + filename);
                         cmd.Parameters.AddWithValue("@Content", bytes);
                         cmd.Parameters.AddWithValue("@FileSize", bytes.Length.ToString());
                         cmd.Parameters.AddWithValue("@SaveDateTime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                         cmd.Parameters.AddWithValue("@UserName", _USER_NAME);
                         con.Open();
                         cmd.ExecuteNonQuery();
                         con.Close();
                     }
                 }
             }
         }
         Common._NotificationShow("上传成功");
         AddWindow.Close();
         show_grid();
     }
     catch (Exception ex)
     {
         Common._ErrorMsgShow("上传失败:" + ex.Message.ToString());
     }
 }
Example #7
0
 private void Cancel_Click(object sender, RoutedEventArgs e)
 {
     AddWindow.Close();
 }
Example #8
0
 public void Close()
 {
     AddWindow.Close();
     AddWindow = new AddWindow();
     _open     = false;
 }