/// <summary> /// 检查职位名是否存在 /// </summary> protected void CheckDutyName() { string str = String.Empty; string id = Utils.GetQueryStringValue("id"); string name = Utils.GetQueryStringValue("name"); if (!string.IsNullOrEmpty(name)) { BPosition BLL = new BPosition(); if (String.IsNullOrEmpty(id)) {//新增 if (BLL.ExistsNum(name, 0, this.SiteUserInfo.CompanyId)) { str = "1"; } } else { //更新 MGovPosition Model = BLL.GetGovPositionModel(Utils.GetInt(id), this.SiteUserInfo.CompanyId); if (null != Model && !string.Equals(name, Model.Title)) { if (BLL.ExistsNum(name, 0, this.SiteUserInfo.CompanyId)) { str = "1"; } } } } Response.Clear(); Response.Write(str); Response.End(); }
private async Task <bool> PerformMove(BPosition p1, BPosition p2) { if (p1 == null || p2 == null) { return(await Task.Run(() => false)); } var old = _state; _state = _state.GetWithMove(p1, p2); var res = await StateChanged?.Invoke(_state); if (res) { var figure = GetPieceAt(p1.Row, p1.Column); MovePiece(figure.Coordinates, new Point(p2.Column + 1, 8 - p2.Row)); } else { _state = old; } ClearPieceSelection(); UnHighlightAllCells(); _selection = null; return(res); }
async void _3DChess_MouseDown(object sender, MouseButtonEventArgs e) { Point location = e.GetPosition(_3DChess); ChessPiece cp = GetHitTestResult(location); if (cp != null) { if (_selection != null && cp == GetPieceAt(_selection.Row, _selection.Column)) { _selection = null; ClearPieceSelection(); return; } else if (_selection != null) { await PerformMove(_selection, new BPosition(8 - (int)cp.Coordinates.Y, (int)cp.Coordinates.X - 1)); } else if (_selection == null) { _state.LastMove = new Tuple <BPosition, BPosition>( new BPosition(8 - (int)cp.Coordinates.Y, (int)cp.Coordinates.X), new BPosition(0, 0)); _selection = new BPosition(8 - (int)cp.Coordinates.Y, (int)cp.Coordinates.X - 1); var poses = GetMovesFrom(_selection); HightLightCells(poses); PiecePicked?.Invoke(cp, new System.EventArgs()); } } }
/// <summary> /// 删除操作 /// </summary> /// <param name="id">删除ID</param> /// <returns></returns> private void DeleteData(string id) { int flag = 0; string str = string.Empty; if (!String.IsNullOrEmpty(id)) { BPosition BLL = new BPosition(); flag = BLL.DeleteGovPosition(id.Split(',')); } switch (flag) { case 0: str = "删除失败!"; break; case 1: str = "删除成功!"; //成功 break; case 2: str = "删除失败,职务正在使用中!"; break; } //返回ajax操作结果 Response.Clear(); Response.Write(UtilsCommons.AjaxReturnJson(flag.ToString(), str)); Response.End(); }
/// <summary> /// 保存 /// </summary> protected void PageSave(string doType) { #region 表单取值 string msg = ""; bool result = false; Response.Clear(); //职位名称 string dutyName = Utils.GetFormValue(txtDutyName.UniqueID); //职位说明书 string content = Utils.GetFormValue(txtContent.UniqueID); //职位编号 string dutyId = Utils.GetFormValue(hidDutyId.UniqueID); #endregion #region 表单验证 if (string.IsNullOrEmpty(dutyName)) { msg += "-请输入职务名称!"; } if (string.IsNullOrEmpty(content)) { msg += "-请输入职务描述!"; } if (!string.IsNullOrEmpty(msg)) { result = false; Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); return; } #endregion #region 提交回应 BPosition BLL = new BPosition(); MGovPosition Model; if (doType == "add") { Model = new MGovPosition(); this.commonModel(Model, dutyName, content); result = BLL.AddGovPosition(Model); msg = result ? "添加成功!" : "添加失败!"; } if (doType == "update") { Model = BLL.GetGovPositionModel(Utils.GetInt(dutyId), this.SiteUserInfo.CompanyId); if (null != Model) { this.commonModel(Model, dutyName, content); Model.PositionId = Int32.Parse(dutyId); result = BLL.UpdateGovPosition(Model); msg = result ? "修改成功!" : "修改失败!"; } } Response.Clear(); Response.Write(UtilsCommons.AjaxReturnJson(result ? "1" : "0", msg)); Response.End(); #endregion }
private async void PerformClick(int i, int j) { if (_selection == null && HaveFigureOn(i, j)) { _selection = new BPosition(i, j); var poses = GetMovesFrom(_selection); HightLightCells(poses); } else { await PerformMove(_selection, new BPosition(i, j)); UnHighlightAllCells(); } }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit(string id) { BPosition BLL = new BPosition(); MGovPosition Model = BLL.GetGovPositionModel(Utils.GetInt(id), this.SiteUserInfo.CompanyId); if (null != Model) { this.txtDutyName.Text = Model.Title; //职位名 this.txtContent.Text = Model.Description; //职位说明 this.hidDutyId.Value = Model.PositionId.ToString(); if (!this.SiteUserInfo.IsHandleElse && this.SiteUserInfo.UserId != Model.OperatorId) { this.ph_Save.Visible = false; } } }
internal static string ConvertChessPosition(BPosition point) { return((char)(point.Column + (int)'A') + (8 - point.Row).ToString()); }