private void btnSave_Click(object sender, EventArgs e) { #region Validation controls if (tbItem.Text.Trim().Length == 0) { ShowError(zh?"请输入产品":"Please fill the item", tbItem, lbError); return; } HideError(tbItem, lbError); if (tbNZPrice.Text.Trim().Length == 0) { ShowError(zh?"请输入纽币价格":"Please fill the blank", tbNZPrice, lbError); return; } if (Regex.IsMatch(tbNZPrice.Text, "[^0-9]")) //区分不是字母,而是数字 { if (!Regex.IsMatch(tbNZPrice.Text, @"^(-?\d+)(\.\d+)?$")) { //不是小数 ShowError(zh?"只允许输入数字":"Please input only number", tbNZPrice, lbError); return; } else { HideError(tbNZPrice, lbError); } } else { HideError(tbNZPrice, lbError); } #endregion #region Generate BrowseHistory file var objItem = new Item { ItemDescription = tbItem.Text.Trim(), UnitPrice = Convert.ToDouble(lbResult.Text), CreateTime = DateTime.Now.Date }; ExportFile.CreateOrUpdateBrowseHistoryFile(@"BrowsingHistory.txt", objItem); #endregion #region Read BrowseHistory file ReadBrowsingHistory(); #endregion #region Controls updating var chkSelected = (DataGridViewCheckBoxCell)dgvPriceHistory.Rows[0].Cells[0]; chkSelected.Value = true; ClearControls(); #endregion }