/* * 更新 */ public int update(DControlEvent entity) { string sql = "update dControlEvent set dControlId=@dControlId,turnPictureImagesId=@turnPictureImagesId,screenCfgId=@screenCfgId" + ",linkToPageId=@linkToPageId,isDialogLink=@isDialogLink" + ",showInWhichCFrame=@showInWhichCFrame,isTransparentDialog=@isTransparentDialog" + " where id=@id"; SQLiteParameter[] parameters = { new SQLiteParameter("@dControlId", DbType.Int32, 4), new SQLiteParameter("@turnPictureImagesId", DbType.Int32, 4), new SQLiteParameter("@screenCfgId", DbType.Int32, 4), new SQLiteParameter("@linkToPageId", DbType.Int32, 4), new SQLiteParameter("@isDialogLink", DbType.Int32, 4), new SQLiteParameter("@showInWhichCFrame", DbType.Int32, 4), new SQLiteParameter("@isTransparentDialog", DbType.Int32, 4), new SQLiteParameter("@id", DbType.Int32, 4) }; parameters[0].Value = entity.dControlId; parameters[1].Value = entity.turnPictureImagesId; parameters[2].Value = entity.screenCfgId; parameters[3].Value = entity.linkToPageId; parameters[4].Value = entity.isDialogLink; parameters[5].Value = entity.showInWhichCFrame; parameters[6].Value = entity.isTransparentDialog; parameters[7].Value = entity.id; int result = Common.SQLiteHelper.ExecuteNonQuery(sql, parameters); return(result); }
/* * 插入 */ public DControlEvent insert(DControlEvent entity) { String sql = "insert into dControlEvent(dControlId,turnPictureImagesId,screenCfgId,linkToPageId,isDialogLink,showInWhichCFrame,isTransparentDialog) "; sql = sql + " values(@dControlId,@turnPictureImagesId,@screenCfgId,@linkToPageId,@isDialogLink,@showInWhichCFrame,@isTransparentDialog);select last_insert_rowid();"; SQLiteParameter[] parameters = { new SQLiteParameter("@dControlId", DbType.Int32, 4), new SQLiteParameter("@turnPictureImagesId", DbType.Int32, 4), new SQLiteParameter("@screenCfgId", DbType.Int32, 4), new SQLiteParameter("@linkToPageId", DbType.Int32, 4), new SQLiteParameter("@isDialogLink", DbType.Int32, 4), new SQLiteParameter("@showInWhichCFrame", DbType.Int32, 4), new SQLiteParameter("@isTransparentDialog", DbType.Int32, 4) }; parameters[0].Value = entity.dControlId; parameters[1].Value = entity.turnPictureImagesId; parameters[2].Value = entity.screenCfgId; parameters[3].Value = entity.linkToPageId; parameters[4].Value = entity.isDialogLink; parameters[5].Value = entity.showInWhichCFrame; parameters[6].Value = entity.isTransparentDialog; DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters); int id = DataType.ToInt32(dt.Rows[0]["last_insert_rowid()"].ToString()); entity.id = id; return(entity); }
/* * 获取轮播图片在某个屏幕对应的跳转 */ public DControlEvent getByTurnPictureImagesIdScreenCfgId(int turnPictureImagesId, int screenCfgId) { String sql = "select * from dControlEvent where turnPictureImagesId=@turnPictureImagesId and screenCfgId=@screenCfgId "; SQLiteParameter[] parameters = { new SQLiteParameter("@turnPictureImagesId", DbType.Int32, 4), new SQLiteParameter("@screenCfgId", DbType.Int32, 4) }; parameters[0].Value = turnPictureImagesId; parameters[1].Value = screenCfgId; DataTable dt = Common.SQLiteHelper.ExecuteQuery(sql, parameters); if (dt == null || dt.Rows.Count <= 0) { return(null); } DControlEvent entity = DataToEntity <DControlEvent> .FillModel(dt.Rows[0]); return(entity); }
/* * 插入 */ public DControlEvent insert(DControlEvent dControlEvent) { return(dControlEventDal.insert(dControlEvent)); }
/* * 更新 */ public DControlEvent update(DControlEvent dControlEvent) { int rows = dControlEventDal.update(dControlEvent); return(dControlEvent); }
private void loadPageData() { List <ScreenCfg> screenCfgList = screenCfgBll.findAll(); TabControl tabControl = new TabControl(); tabControl.Width = 900; tabControl.Height = 500; tabControl.TabStripPlacement = Dock.Top; tabControl.BorderThickness = new Thickness(0, 1, 0, 0); tabControl.Padding = new Thickness(0, 0, 0, 0); tabControl.HorizontalAlignment = HorizontalAlignment.Left; tabControl.VerticalAlignment = VerticalAlignment.Top; foreach (ScreenCfg sc in screenCfgList) { DControlEvent dControlEvent = dControlEventBll.getByTurnPictureImagesIdScreenCfgId(dto.id, sc.id); TabItem tabItem = new TabItem(); tabItem.Header = sc.diyName; tabItem.Tag = sc.id; tabItem.Padding = new Thickness(15, 5, 15, 5); Grid grid = new Grid(); grid.Background = Brushes.White; tabItem.Content = grid; //1.选择页面 Label label1 = new Label(); label1.Content = "请选择页面:"; label1.Margin = new Thickness(61, 48, 0, 0); label1.Width = 110; label1.Height = 30; label1.HorizontalAlignment = HorizontalAlignment.Left; label1.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(label1); ComboBox comboBoxLinkToPageId = new ComboBox(); comboBoxLinkToPageId.Name = "linkToPageId" + sc.id; comboBoxLinkToPageId.Margin = new Thickness(61, 92, 0, 0); comboBoxLinkToPageId.Width = 250; comboBoxLinkToPageId.Height = 30; comboBoxLinkToPageId.HorizontalAlignment = HorizontalAlignment.Left; comboBoxLinkToPageId.VerticalAlignment = VerticalAlignment.Top; comboBoxLinkToPageId.VerticalContentAlignment = VerticalAlignment.Center; grid.Children.Add(comboBoxLinkToPageId); //2.显示位置 Label label2 = new Label(); label2.Content = "显示位置:"; label2.Margin = new Thickness(61, 168, 0, 0); label2.Width = 110; label2.Height = 30; label2.HorizontalAlignment = HorizontalAlignment.Left; label2.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(label2); ComboBox comboBoxShowInWhichCFrame = new ComboBox(); comboBoxShowInWhichCFrame.Name = "showInWhichCFrame" + sc.id; comboBoxShowInWhichCFrame.Margin = new Thickness(61, 202, 0, 0); comboBoxShowInWhichCFrame.MinWidth = 200; comboBoxShowInWhichCFrame.Height = 30; comboBoxShowInWhichCFrame.HorizontalAlignment = HorizontalAlignment.Left; comboBoxShowInWhichCFrame.VerticalAlignment = VerticalAlignment.Top; comboBoxShowInWhichCFrame.VerticalContentAlignment = VerticalAlignment.Center; grid.Children.Add(comboBoxShowInWhichCFrame); //3.弹窗 CheckBox checkBoxIsDialogLink = new CheckBox(); checkBoxIsDialogLink.Name = "isDialogLink" + sc.id; checkBoxIsDialogLink.Margin = new Thickness(341, 102, 0, 0); checkBoxIsDialogLink.Content = "弹窗"; checkBoxIsDialogLink.HorizontalAlignment = HorizontalAlignment.Left; checkBoxIsDialogLink.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(checkBoxIsDialogLink); CheckBox checkBoxIsTransparentDialog = new CheckBox(); checkBoxIsTransparentDialog.Name = "isTransparentDialog" + sc.id; checkBoxIsTransparentDialog.Margin = new Thickness(435, 102, 0, 0); checkBoxIsTransparentDialog.Content = "透明弹窗"; checkBoxIsTransparentDialog.HorizontalAlignment = HorizontalAlignment.Left; checkBoxIsTransparentDialog.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(checkBoxIsTransparentDialog); //<Button Name="image" Content="" HorizontalAlignment="Left" Margin="654,48,0,0" VerticalAlignment="Top" Width="200" Height="200"/> Button buttonImage = new Button(); buttonImage.Margin = new Thickness(654, 48, 0, 0); buttonImage.Width = 200; buttonImage.Height = 200; buttonImage.HorizontalAlignment = HorizontalAlignment.Left; buttonImage.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(buttonImage); int linkToPageIdVal = dControlEvent == null ? 0 : dControlEvent.linkToPageId; int showInWhichCFrameVal = dControlEvent == null ? 0 : dControlEvent.showInWhichCFrame; bool isTransparentDialogVal = dControlEvent == null ? false : dControlEvent.isTransparentDialog; bool isDialogLinkVal = dControlEvent == null ? false : dControlEvent.isDialogLink; //如果不是弹窗,则显示选择的页面 this.initCombox_linkToPageId(comboBoxLinkToPageId, linkToPageIdVal); this.initCombox_showInWhichCFrame(comboBoxShowInWhichCFrame, showInWhichCFrameVal); checkBoxIsTransparentDialog.IsChecked = isTransparentDialogVal; checkBoxIsDialogLink.IsChecked = isDialogLinkVal; this.initCurrImage(buttonImage, dto); tabControl.Items.Add(tabItem); } mainGrid.Children.Add(tabControl); }
private void Submit_Button_Click(object sender, RoutedEventArgs e) { /* * 获取不同屏幕下 linkToPageId,showInWhichCFrame的值 * * 如果数据库中有数据行则更新,没有则插入 */ bool isLink = false; foreach (FrameworkElement ele in mainGrid.Children) { if (ele is TabControl == false) { continue; } TabControl tabControl = (TabControl)ele; foreach (TabItem tabItem in tabControl.Items) { int screenCfgId = Convert.ToInt32(tabItem.Tag); int linkToPageIdVal = 0; int showInWhichCFrameVal = 0; bool isTransparentDialogVal = false; bool isDialogLinkVal = false; Grid grid = (Grid)tabItem.Content; foreach (FrameworkElement fe in grid.Children) { if (fe.Name == "linkToPageId" + screenCfgId) { ComboBox comboBoxLinkToPageId = (ComboBox)fe; ComboBoxItem item = (ComboBoxItem)comboBoxLinkToPageId.SelectedItem; if (item != null) { linkToPageIdVal = (int)item.Tag; } } if (fe.Name == "showInWhichCFrame" + screenCfgId) { ComboBox comboBoxShowInWhichCFrame = (ComboBox)fe; ComboBoxItem item = (ComboBoxItem)comboBoxShowInWhichCFrame.SelectedItem; if (item != null) { showInWhichCFrameVal = (int)item.Tag; } } if (fe.Name == "isTransparentDialog" + screenCfgId) { CheckBox checkBoxIsTransparentDialog = (CheckBox)fe; isTransparentDialogVal = (Boolean)checkBoxIsTransparentDialog.IsChecked; } if (fe.Name == "isDialogLink" + screenCfgId) { CheckBox checkBoxIsDialogLink = (CheckBox)fe; isDialogLinkVal = (Boolean)checkBoxIsDialogLink.IsChecked; } } if (linkToPageIdVal > 0) { isLink = true; } DControlEvent dControlEvent = dControlEventBll.getByTurnPictureImagesIdScreenCfgId(dto.id, screenCfgId); if (dControlEvent != null) { dControlEvent.linkToPageId = linkToPageIdVal; dControlEvent.showInWhichCFrame = showInWhichCFrameVal; dControlEvent.isDialogLink = isDialogLinkVal; dControlEvent.isTransparentDialog = isTransparentDialogVal; dControlEventBll.update(dControlEvent); } else { dControlEvent = new DControlEvent(); dControlEvent.turnPictureImagesId = dto.id; dControlEvent.screenCfgId = screenCfgId; dControlEvent.linkToPageId = linkToPageIdVal; dControlEvent.showInWhichCFrame = showInWhichCFrameVal; dControlEvent.isDialogLink = isDialogLinkVal; dControlEvent.isTransparentDialog = isTransparentDialogVal; dControlEventBll.insert(dControlEvent); } } } //更新到数据库 TurnPictureImages turnPictureImages = turnPictureImagesBll.get(dto.id); turnPictureImages.isLink = isLink; turnPictureImagesBll.update(turnPictureImages); //更新到上一个页面 dto.isLink = isLink; Canvas imgCanvas = (Canvas)VisualTreeHelper.GetParent(linkBtn); imgCanvas.Tag = dto; //更新是否有链接的标志 if (isLink) { linkBtn.Background = new ImageBrush { ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + "/myfile/sysimg/ico-image-link-active.png") , Stretch = Stretch.Uniform }; } else { linkBtn.Background = new ImageBrush { ImageSource = FileUtil.readImage(AppDomain.CurrentDomain.BaseDirectory + "/myfile/sysimg/ico-image-link.png") , Stretch = Stretch.Uniform }; } Close(); }
private void loadPageData() { List <ScreenCfg> screenCfgList = screenCfgBll.findAll(); TabControl tabControl = new TabControl(); tabControl.Width = 900; tabControl.Height = 500; tabControl.TabStripPlacement = Dock.Top; tabControl.BorderThickness = new Thickness(0, 1, 0, 0); tabControl.Padding = new Thickness(0, 0, 0, 0); tabControl.HorizontalAlignment = HorizontalAlignment.Left; tabControl.VerticalAlignment = VerticalAlignment.Top; foreach (ScreenCfg sc in screenCfgList) { DControlEvent dControlEvent = dControlEventBll.getByDControlIdScreenCfgId(currDControl.id, sc.id); TabItem tabItem = new TabItem(); tabItem.Header = sc.diyName; tabItem.Tag = sc.id; tabItem.Padding = new Thickness(15, 5, 15, 5); Grid grid = new Grid(); grid.Background = Brushes.White; tabItem.Content = grid; //1.选择页面 Label label1 = new Label(); label1.Content = "请选择弹窗页面:"; label1.Margin = new Thickness(127, 51, 0, 0); label1.Width = 110; label1.Height = 30; label1.HorizontalAlignment = HorizontalAlignment.Left; label1.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(label1); ComboBox comboBoxLinkToPageId = new ComboBox(); comboBoxLinkToPageId.Name = "linkToPageId" + sc.id; comboBoxLinkToPageId.Margin = new Thickness(135, 80, 0, 0); comboBoxLinkToPageId.MinWidth = 200; comboBoxLinkToPageId.Height = 30; comboBoxLinkToPageId.HorizontalAlignment = HorizontalAlignment.Left; comboBoxLinkToPageId.VerticalAlignment = VerticalAlignment.Top; comboBoxLinkToPageId.VerticalContentAlignment = VerticalAlignment.Center; grid.Children.Add(comboBoxLinkToPageId); //2.显示位置 Label label2 = new Label(); label2.Content = "在哪个窗口弹窗:"; label2.Margin = new Thickness(135, 142, 0, 0); label2.Width = 110; label2.Height = 30; label2.HorizontalAlignment = HorizontalAlignment.Left; label2.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(label2); ComboBox comboBoxShowInWhichCFrame = new ComboBox(); comboBoxShowInWhichCFrame.Name = "showInWhichCFrame" + sc.id; comboBoxShowInWhichCFrame.Margin = new Thickness(135, 176, 0, 0); comboBoxShowInWhichCFrame.MinWidth = 200; comboBoxShowInWhichCFrame.Height = 30; comboBoxShowInWhichCFrame.HorizontalAlignment = HorizontalAlignment.Left; comboBoxShowInWhichCFrame.VerticalAlignment = VerticalAlignment.Top; comboBoxShowInWhichCFrame.VerticalContentAlignment = VerticalAlignment.Center; grid.Children.Add(comboBoxShowInWhichCFrame); // < CheckBox x: Name = "isTransparentDialog" Content = "透明弹窗" HorizontalAlignment = "Left" Margin = "387,207,0,0" VerticalAlignment = "Top" /> CheckBox checkBoxIsTransparentDialog = new CheckBox(); checkBoxIsTransparentDialog.Name = "isTransparentDialog" + sc.id; checkBoxIsTransparentDialog.Margin = new Thickness(387, 176, 0, 0); checkBoxIsTransparentDialog.Content = "透明弹窗"; //checkBoxIsTransparentDialog.MinWidth = 200; //checkBoxIsTransparentDialog.Height = 30; checkBoxIsTransparentDialog.HorizontalAlignment = HorizontalAlignment.Left; checkBoxIsTransparentDialog.VerticalAlignment = VerticalAlignment.Top; grid.Children.Add(checkBoxIsTransparentDialog); int linkToPageIdVal = dControlEvent == null ? 0 : dControlEvent.linkToPageId; int showInWhichCFrameVal = dControlEvent == null ? 0 : dControlEvent.showInWhichCFrame; bool isTransparentDialogVal = dControlEvent == null ? false : dControlEvent.isTransparentDialog; bool isDialogLinkVal = dControlEvent == null ? false : dControlEvent.isDialogLink; //如果是弹窗,则显示选择的页面 if (isDialogLinkVal) { this.initCombox_linkToPageId(comboBoxLinkToPageId, linkToPageIdVal); this.initCombox_showInWhichCFrame(comboBoxShowInWhichCFrame, showInWhichCFrameVal); checkBoxIsTransparentDialog.IsChecked = isTransparentDialogVal; } else { this.initCombox_linkToPageId(comboBoxLinkToPageId, 0); this.initCombox_showInWhichCFrame(comboBoxShowInWhichCFrame, 0); checkBoxIsTransparentDialog.IsChecked = false; } tabControl.Items.Add(tabItem); } mainGrid.Children.Add(tabControl); //if (currDControl.isDialogLink) //{ // initCombox_linkToPageId(currDControl.linkToPageId); // initCombox_showInWhichCFrame(currDControl.showInWhichCFrame); // isTransparentDialog.IsChecked = currDControl.isTransparentDialog; //} //else //{ // initCombox_linkToPageId(0); // initCombox_showInWhichCFrame(0); // isTransparentDialog.IsChecked = false; //} //initCombox_screenCfgId(currDControl.screenCfgId); }
private void Submit_Button_Click(object sender, RoutedEventArgs e) { /* * 获取不同屏幕下 linkToPageId,showInWhichCFrame的值 * * 如果数据库中有数据行则更新,没有则插入 */ foreach (FrameworkElement ele in mainGrid.Children) { if (ele is TabControl == false) { continue; } TabControl tabControl = (TabControl)ele; foreach (TabItem tabItem in tabControl.Items) { int screenCfgId = Convert.ToInt32(tabItem.Tag); int linToPageIdVal = 0; int showInWhichCFrameVal = 0; Boolean isTransparentDialogVal = false; Grid grid = (Grid)tabItem.Content; foreach (FrameworkElement fe in grid.Children) { if (fe.Name == "linkToPageId" + screenCfgId) { ComboBox comboBoxLinkToPageId = (ComboBox)fe; ComboBoxItem item = (ComboBoxItem)comboBoxLinkToPageId.SelectedItem; if (item != null) { linToPageIdVal = (int)item.Tag; } } if (fe.Name == "showInWhichCFrame" + screenCfgId) { ComboBox comboBoxShowInWhichCFrame = (ComboBox)fe; ComboBoxItem item = (ComboBoxItem)comboBoxShowInWhichCFrame.SelectedItem; if (item != null) { showInWhichCFrameVal = (int)item.Tag; } } if (fe.Name == "isTransparentDialog" + screenCfgId) { CheckBox checkBoxIsTransparentDialog = (CheckBox)fe; isTransparentDialogVal = (Boolean)checkBoxIsTransparentDialog.IsChecked; } } DControlEvent dControlEvent = dControlEventBll.getByDControlIdScreenCfgId(currDControl.id, screenCfgId); if (dControlEvent != null) { dControlEvent.linkToPageId = linToPageIdVal; dControlEvent.showInWhichCFrame = showInWhichCFrameVal; dControlEvent.isTransparentDialog = isTransparentDialogVal; //当页面没有填数据,则保留原来的值isDialogLink if (linToPageIdVal != 0 || showInWhichCFrameVal != 0 || isTransparentDialogVal == true) { dControlEvent.isDialogLink = true; } dControlEventBll.update(dControlEvent); } else { dControlEvent = new DControlEvent(); dControlEvent.dControlId = currDControl.id; dControlEvent.screenCfgId = screenCfgId; dControlEvent.linkToPageId = linToPageIdVal; dControlEvent.showInWhichCFrame = showInWhichCFrameVal; dControlEvent.isDialogLink = true; dControlEvent.isTransparentDialog = isTransparentDialogVal; dControlEventBll.insert(dControlEvent); } } } Close(); }