Exemplo n.º 1
0
        private void InitSelectClass()
        {
            var classAlist = new BLL.ClassAModelBLL().GetAll();
            List <Models.ClassBModel> classBlist = new BLL.ClassBModelBLL().GetAll();

            //控件列表
            List <Controls.MainClassPanel> classCtrlList = new List <Controls.MainClassPanel>();

            foreach (var classA in classAlist)                                                                //循环主类
            {
                List <Models.ClassBModel> ClassBList = classBlist.FindAll(s => s.ClassA == classA.ClassName); //选择某一子类

                List <RadioButton> roomControl = new List <RadioButton>();

                var floorPanel = new Controls.MainClassPanel {
                    ClassAname = classA.ClassName, Dock = DockStyle.Top, AutoSize = true
                };
                floorPanel.comboBox1.DataSource    = ClassBList;
                floorPanel.comboBox1.DisplayMember = "classB";
                floorPanel.comboBox1.ValueMember   = "classB";
                classCtrlList.Add(floorPanel);
            }

            if (this.InvokeRequired)
            {
                this.BeginInvoke(new MethodInvoker(delegate { panelRoomList.Controls.AddRange(classCtrlList.ToArray()); }));
            }
            else
            {
                panelRoomList.Controls.AddRange(classCtrlList.ToArray());
            }
        }
Exemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string errMsg = string.Empty;

            // if (pictureBox1.Image == null) errMsg += "请选择图片!\r\n";
            if (lbID.Text == "lbID")
            {
                errMsg += "请点击您要修改的记录!\r\n";
            }

            string errSubClass = "";//判断子分类
            List <Models.ClassJson> classJson = new List <ClassJson>();

            foreach (Panel item in panelRoomList.Controls)
            {
                if (item.Name != "panelSave")
                {
                    Controls.MainClassPanel panel = item as Controls.MainClassPanel;
                    errSubClass += panel.comboBox1.Text.Trim();

                    //计算分类
                    classJson.Add(new ClassJson()
                    {
                        ClassA = panel.ClassAname, ClassB = panel.comboBox1.Text.Trim()
                    });
                    //存盘子类
                    saveClassB(panel.ClassAname, panel.comboBox1.Text.Trim());
                }
            }
            if (errSubClass == "")
            {
                errMsg += "请至少选择一个子分类!\r\n";
            }

            //准备存盘
            if (string.IsNullOrEmpty(errMsg))
            {
                //2.保存信息到数据库


                int id = Convert.ToInt32(lbID.Text);
                Models.FileInfoModel info = new BLL.FileInfoModelBLL().GetById(id);

                info.ClassJson = JsonConvert.SerializeObject(classJson);
                info.Memo      = tbMemo.Text;
                new BLL.FileInfoModelBLL().Update(info);
                MessageBox.Show("修改成功!");

                //3.刷新gridview
                BindDataWithPage(1, _sqlWhere);
            }
            else
            {
                MessageBox.Show(errMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string errMsg = string.Empty;

            if (imageBox1.Image == null)
            {
                errMsg += "请扫描或上传图片!\r\n";
            }


            string errSubClass = "";//判断子分类
            List <Models.ClassJson> classJson = new List <ClassJson>();

            foreach (Panel item in panelRoomList.Controls)
            {
                if (item.Name != "panelSave")
                {
                    Controls.MainClassPanel panel = item as Controls.MainClassPanel;
                    errSubClass += panel.comboBox1.Text.Trim();

                    //计算分类
                    classJson.Add(new ClassJson()
                    {
                        ClassA = panel.ClassAname, ClassB = panel.comboBox1.Text.Trim()
                    });
                    //存盘子类
                    saveClassB(panel.ClassAname, panel.comboBox1.Text.Trim());
                }
            }
            if (errSubClass == "")
            {
                errMsg += "请至少选择一个子分类!\r\n";
            }

            if (string.IsNullOrEmpty(_picBoxTempfile))
            {
                errMsg += "请扫描或上传一个图片文件!\r\n";
            }
            //准备存盘
            if (string.IsNullOrEmpty(errMsg) && !string.IsNullOrEmpty(_picBoxTempfile))
            {
                string uploadFile = DateTime.Now.ToString("yyyyMMddHHmmss") + ".png";

                //1. 复制图片
                if (_previewImage == null)
                {
                    File.Copy(_picBoxTempfile, ConfigHelper.UpLoadPath + uploadFile);
                }
                else
                {
                    using (MemoryStream mem = new MemoryStream())
                    {
                        Bitmap bmp = new Bitmap(imageBox1.Image);
                        bmp.Save(ConfigHelper.UpLoadPath + uploadFile, imageBox1.Image.RawFormat);
                        bmp.Dispose();
                    }
                }
                //2.保存信息到数据库
                SaveData(uploadFile, JsonConvert.SerializeObject(classJson));

                //3.清空picbox
                imageBox1.Image = global::ieeve.com.Properties.Resources.bg;
                bindListView(listViewCamera, imageListCamera, ConfigHelper.TempPath);
            }
            else
            {
                MessageBox.Show(errMsg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }