/// <summary> /// 新增 /// </summary> /// <param name="model"></param> public static void AddRegion(BizRegion model) { string sql = string.Format(@" INSERT INTO dbo.tbl_Region ( RegionName, Zipcode, Phone, Disabled, ProvinceID, CityID, DistrictID, IsBusiness, IsInstall, Tag, ParentID, IsActive, LastUpdateTime, TuhuStockID, LogisticStockID, ExpCompany, LogisticCo, ArriveShopExpCo, PinYin ) VALUES ( N'{0}', N'', N'', 0, {1}, {2}, 0, 0, 0, N'', {3}, 1, GETDATE(), 0, 0, N'', N'', N'', N'{4}' )" , model.RegionName, model.ProvinceId, model.CityId, model.ParentId, model.PinYin); DbHelper.ExecuteNonQuery(sql, CommandType.Text); }
public static List <BizRegion> SelectRegions(int parent = 0) { var sql = "select PKID as Pkid,RegionName,ProvinceID,CityID from tbl_region where (ParentID=@ParentID OR @ParentID=-1) AND IsActive=1 "; #region 参数 var sqlParamters = new[] { new SqlParameter("@ParentID", parent) }; #endregion var list = SqlHelper.ExecuteDataTable(connAlwaysOnRead, CommandType.Text, sql, sqlParamters).ConvertTo <BizRegion>().ToList(); BizRegion region = new BizRegion(); region.Pkid = -1; region.RegionName = "-请选择-"; list.Add(region); return(list.OrderBy(n => n.Pkid).ToList()); }
public static BizRegion GetRegionsOne(int pkid) { var sql = "select PKID as Pkid,RegionName,PinYin,ProvinceID,CityID from tbl_region where PKID=@PKID AND IsActive=1 "; #region 参数 var sqlParamters = new[] { new SqlParameter("@PKID", pkid) }; #endregion var list = SqlHelper.ExecuteDataTable(connAlwaysOnRead, CommandType.Text, sql, sqlParamters).ConvertTo <BizRegion>().ToList(); BizRegion region = new BizRegion(); region.Pkid = list[0].Pkid; region.RegionName = list[0].RegionName; region.PinYin = list[0].PinYin; region.ProvinceId = list[0].ProvinceId; region.CityId = list[0].CityId; return(region); }
private void btnRegion_Click(object sender, EventArgs e) { CrystalButton btnRegion = sender as CrystalButton; if (btnRegion == null) { return; } BizRegion region = btnRegion.Tag as BizRegion; if (region == null) { return; } _currentFormActivate = false; lock (_dicDeskInRegion) { //禁止引发Layout事件 this.pnlDesk.SuspendLayout(); this.SuspendLayout(); //清除pnlDesk内所有控件 this.pnlDesk.Controls.Clear(); //获取Desk List _prevRegionButton.BackColor = _prevRegionButton.DisplayColor; btnRegion.BackColor = ConstantValuePool.PressedColor; _prevRegionButton = btnRegion; _currentRegionId = region.RegionID; if (!_dicDeskInRegion.ContainsKey(_currentRegionId)) { List <CrystalButton> btnList = new List <CrystalButton>(); if (region.BizDeskList != null && region.BizDeskList.Count > 0) { foreach (BizDesk desk in region.BizDeskList) { CrystalButton btn = new CrystalButton(); btn.Name = desk.DeskID.ToString(); btn.Text = desk.DeskName; btn.Width = desk.Width; btn.Height = desk.Height; btn.Location = new Point(desk.PX, desk.PY); btn.Tag = desk; btn.Font = new Font("Arial", ConstantValuePool.BizSettingConfig.FontSize, FontStyle.Regular); btn.ForeColor = Color.White; btn.BackColor = GetColorByStatus(desk.Status, desk.DeviceNo); btn.Click += new System.EventHandler(this.btnDesk_Click); btnList.Add(btn); } } _dicDeskInRegion.Add(region.RegionID, btnList); } foreach (CrystalButton btn in _dicDeskInRegion[region.RegionID]) { this.pnlDesk.Controls.Add(btn); } this.pnlDesk.Controls.Add(btnFreeColor); this.pnlDesk.Controls.Add(btnTakeColor); this.pnlDesk.Controls.Add(btnLookColor); //恢复引发Layout事件 this.pnlDesk.ResumeLayout(false); this.pnlDesk.PerformLayout(); this.ResumeLayout(false); } _currentFormActivate = true; }
private void InitializeRegionDeskButton() { //禁止引发Layout事件 this.pnlRegion.SuspendLayout(); this.pnlDesk.SuspendLayout(); this.SuspendLayout(); //动态加载区域控件 foreach (BizRegion region in ConstantValuePool.RegionList) { CrystalButton btn = new CrystalButton(); btn.Name = region.RegionID.ToString(); btn.Text = region.RegionName; btn.Width = region.Width; btn.Height = region.Height; btn.Location = new Point(region.PX, region.PY); btn.Tag = region; foreach (ButtonStyle btnStyle in ConstantValuePool.ButtonStyleList) { if (region.ButtonStyleID.Equals(btnStyle.ButtonStyleID)) { btn.Font = new Font(btnStyle.FontName, (float)btnStyle.FontSize, FontStyle.Regular); btn.ForeColor = ColorConvert.RGB(btnStyle.ForeColor); btn.BackColor = btn.DisplayColor = ColorConvert.RGB(btnStyle.BackColor); break; } } btn.Click += new System.EventHandler(this.btnRegion_Click); if (_prevRegionButton == null) { _prevRegionButton = btn; _prevRegionButton.BackColor = ConstantValuePool.PressedColor; } this.pnlRegion.Controls.Add(btn); } //动态加载第一区域的桌况信息 BizRegion firstRegion = ConstantValuePool.RegionList[0]; _currentRegionId = firstRegion.RegionID; if (!_dicDeskInRegion.ContainsKey(_currentRegionId)) { List <CrystalButton> btnList = new List <CrystalButton>(); foreach (BizDesk desk in firstRegion.BizDeskList) { CrystalButton btn = new CrystalButton(); btn.Name = desk.DeskID.ToString(); btn.Text = desk.DeskName; btn.Width = desk.Width; btn.Height = desk.Height; btn.Location = new Point(desk.PX, desk.PY); btn.Tag = desk; btn.Font = new Font("Arial", ConstantValuePool.BizSettingConfig.FontSize, FontStyle.Regular); btn.ForeColor = Color.White; btn.BackColor = GetColorByStatus(desk.Status, desk.DeviceNo); btn.Click += new System.EventHandler(this.btnDesk_Click); btnList.Add(btn); } _dicDeskInRegion.Add(firstRegion.RegionID, btnList); } foreach (CrystalButton btn in _dicDeskInRegion[firstRegion.RegionID]) { this.pnlDesk.Controls.Add(btn); } //恢复引发Layout事件 this.pnlRegion.ResumeLayout(false); this.pnlRegion.PerformLayout(); this.pnlDesk.ResumeLayout(false); this.pnlDesk.PerformLayout(); this.ResumeLayout(false); }