public void RpcReload() { var data = new ReloadData(); var type = (WeaponType)photonView.Owner.GetWeapon(); var weapon = GameSetting.Instance.Weapons.Find(x => x.Type == type); if (weapon != null && photonView.IsMine) { var magCount = photonView.Owner.GetMagCount((int)type, weapon.MagCount); if (magCount > 0) { data.BulletCount = weapon.MagCapacity; data.MagCount = magCount - 1; photonView.Owner.SetBulletCount((int)type, data.BulletCount); photonView.Owner.SetMagCount((int)type, data.MagCount); } else { data.BulletCount = photonView.Owner.GetBulletCount((int)type, weapon.MagCapacity); } } _message.Publish(new MsgData() { Type = GameConst.MsgPlayReload, Data = data }); }
private void Items_Save_Button_Click(object sender, EventArgs e) { if (!IsValidateItemData(out string message)) { MessageBoxHelper.ShowErrorMessage(message); return; } List <Items> saveData = this.ItemsData.Where(o => o.Status == ModifyMode.Insert || o.Status == ModifyMode.Update).ToList(); if (ItemsDeleteData != null && ItemsDeleteData.Count > 0) { saveData?.InsertRange(0, ItemsDeleteData); } if (saveData?.Count > 0) { ItemsController controller = new ItemsController(); if (controller.SaveItems(saveData)) { MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); ItemsDeleteData = new List <Items>(); this.LoadItemsGridView(); ReloadData.ItemUpdate(); } else { MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000002); } } }
// Start is called before the first frame update void Start() { inventory.InitAllWeapons(transform); failedReload = new ReloadData(failedColor, (RectTransform)slider.transform); perfectReload = new ReloadData(perfectColor, perfectRange); player = GetComponentInParent <PlayerController>(); }
public MyProfileViewModel() { _service = new UserProfileProxy(); ReloadData += async(x, e) => await LoadUserDataAsync(); EditDataCommand = new DelegateCommand(x => EditData()); ChangePasswordCommand = new DelegateCommand(x => ChangePassword()); ReloadData?.Invoke(this, EventArgs.Empty); (App.Current as App).Login += async(x, e) => await LoadUserDataAsync(); }
protected void EditData() { EditDataDialog dialog = new EditDataDialog(); EditUserDataViewModel vm = new EditUserDataViewModel(LoggedUser) { FirstName = FirstName, LastName = LastName, Email = Email, CompanyName = CompanyName }; dialog.DataContext = vm; vm.RequestClose += (x, e) => dialog.Close(); dialog.ShowDialog(); ReloadData?.Invoke(this, EventArgs.Empty); //email! }
private void Save_Button_Click(object sender, EventArgs e) { if (!IsCheckValidate()) { MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000039); return; } List <Customer> saveData = this.CustommersData.Where(o => o.Status == ModifyMode.Insert || o.Status == ModifyMode.Update).ToList(); if (this.CustomersDeleteData != null) { saveData?.InsertRange(0, this.CustomersDeleteData); } if (saveData?.Count > 0) { CustomerController controller = new CustomerController(); if (controller.SaveCustommers(saveData, out string customerID)) { MessageBoxHelper.ShowInfoMessage(BSMessage.BSM000001); CustomersDeleteData = new List <Customer>(); this.LoadGridView(); ReloadData.CustomerUpdate(); // Chọn KH sau khi lưu thành công if (!string.IsNullOrEmpty(customerID)) { Customer_GridView.SetFocusRowByValue("CustomerID", customerID); SelectedRow = Customer_GridView.GetFocusedRow().CastTo <Customer>(); } } else { MessageBoxHelper.ShowErrorMessage(BSMessage.BSM000002); } } }
private void BtnAddProduct_Click(object sender, EventArgs e) { // kiểm tra các trường thông tin cơ bản có bị trống hay không if (txbProductName.Text == "" || txbProductPrice.Text == "" || txbProductQuantity.Text == "") { MessageBox.Show("Không được để trống các trường dữ liệu cơ bản!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } // kiểm tra ở các ô chỉ toàn số có kí tự lạ hay không if (isNumberic(txbProductPrice.Text) == false) { MessageBox.Show("Đơn giá chỉ bao gồm các chữ số!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (isNumberic(txbProductQuantity.Text) == false) { MessageBox.Show("Số lượng chỉ bao gồm các chữ số!", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); return; } if (txbCamera.Text == "" || txbCPU.Text == "" || txbGPU.Text == "" || txbMore.Text == "" || txbOS.Text == "" || txbPin.Text == "" || txbRAM.Text == "" || txbScreen.Text == "" || txbStorage.Text == "") { DialogResult dlgResult = MessageBox.Show("Có một số thông tin về Thông số kĩ thuật còn trống!\n Bạn có muốn tiếp tục?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dlgResult == DialogResult.Cancel) // nếu người dùng khong muốn tiếp tục { return; } } // thực hiện việc thêm 1 sản phẩm mới vào database // chuyển từ image sang byte [] Byte[] arrImage; using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { Image img = Picimage.Image; img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); arrImage = ms.ToArray(); } // lưu thông tin cơ bản vào DTO DTO_Product product = new DTO_Product() { CategoryID = (int)cmbCategories.SelectedValue, ManufacturerID = (int)cmbManufacturer.SelectedValue, ProductImage = arrImage, ProductName = txbProductName.Text, ProductPrice = int.Parse(txbProductPrice.Text.ToString()), ProductQuantity = int.Parse(txbProductQuantity.Text.ToString()) }; // lưu DTO product xuống database bool resultAdd = bus_Product.BUS_AddNewProduct(product); if (resultAdd == false) { MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // get được ID của product vừa được lưu vào bảng SANPHAM dựa vào tên và ID DataTable dtProductInfo = bus_Product.BUS_GetProductInfoByIDAndName(txbProductName.Text, (int)cmbCategories.SelectedValue); if (dtProductInfo == null) { MessageBox.Show("Có lỗi xảy ra khi load dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dtProductInfo.Rows.Count > 0) { try { // lưu thông số cấu hình vào DTO DTO_ProductProfile productProfile = new DTO_ProductProfile() { ProductID = int.Parse(dtProductInfo.Rows[0]["ID_MASP"].ToString()), CPU = txbCPU.Text, GPU = txbGPU.Text, RAM = txbRAM.Text, Storage = txbStorage.Text, Screen = txbScreen.Text, Camera = txbCamera.Text, PIN = txbPin.Text, OS = txbOS.Text, More = txbMore.Text }; // lưu DTO xuống database bool resultAddProductProfile = bus_Product.BUS_AddProductProfile(productProfile); if (resultAddProductProfile == false) { MessageBox.Show("Thêm không thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } catch (Exception ex) { } } else { MessageBox.Show("Không thể thêm thông số kĩ thuật!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } // thêm dữ liệu vào lịch sử nhập kho // TẠI ĐÂY PRODUCT.QUANTITY = 0 VÌ SỐ LƯỢNG SẢN PHẨM THÊM VÀO TRƯỚC ĐÓ ĐÃ CÓ TRONG SANPHAM. // SAU KHI THỰC HIỆN LỆNH NÀY SẼ LẤY TRONG SẢN PHẨM + SỐ TRUYỀN VÀO. // VÌ VẬY THAM SỐ PRODUCT.QUANTITY = 0 SẼ KHÔNG BỊ CỘNG DỒN LÊN. bool result = bus_Product.BUS_AddProduct_History(int.Parse(dtProductInfo.Rows[0]["ID_MASP"].ToString()), product.ProductPrice, 0, DateTime.Now); if (result == false) { MessageBox.Show("Không thể thêm lịch sử nhập kho!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } MessageBox.Show("Thêm sản phẩm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); // khi thêm sp thành công thì gửi 1 sự kiện reload lại tại form cha ReloadData?.Invoke(this, EventArgs.Empty); this.Close(); }