Exemplo n.º 1
0
        private void ButtonOk_Click(object sender, EventArgs e)
        {
            Int32 deviceType         = 0;
            List <JZTestConfig> list = new List <JZTestConfig>();

            if (rb_ylj.Checked)
            {
                deviceType = 1;
                for (int i = 0; i < sheetView1.Rows.Count; i++)
                {
                    Cell rowCell = sheetView1.Cells[i, 2];

                    JZTestConfig c = new JZTestConfig();
                    c.ModuleID     = moduleID;
                    c.SerialNumber = Convert.ToInt32(sheetView1.Cells[i, 1].Value);
                    c.Config       = new List <JZTestCell>();
                    if (rowCell.Value != null && rowCell.Value.ToString().Trim() != "")
                    {
                        JZTestCell cell = new JZTestCell();
                        cell.Name     = JZTestEnum.PHHZ;
                        cell.CellName = sheetView1.Cells[i, 2].Value.ToString();
                        cell.SheetID  = new Guid(sheetView1.Cells[i, 2].Tag.ToString());
                        c.Config.Add(cell);
                        list.Add(c);
                    }
                }
            }
            else if (rb_wnj.Checked)
            {
                deviceType = 2;
                for (int i = 0; i < SheetView2.Rows.Count; i++)
                {
                    Cell rowCell = SheetView2.Cells[i, 2];

                    JZTestConfig c = new JZTestConfig();
                    c.ModuleID     = moduleID;
                    c.SerialNumber = Convert.ToInt32(SheetView2.Cells[i, 1].Value);
                    c.Config       = new List <JZTestCell>();
                    JZTestCell cell = null;
                    if (rowCell.Value != null && rowCell.Value.ToString().Trim() != "")
                    {
                        cell          = new JZTestCell();
                        cell.Name     = JZTestEnum.QFL;
                        cell.CellName = SheetView2.Cells[i, 2].Value.ToString();
                        cell.SheetID  = new Guid(SheetView2.Cells[i, 2].Tag.ToString());
                        c.Config.Add(cell);
                    }
                    rowCell = SheetView2.Cells[i, 4];
                    if (rowCell.Value != null && rowCell.Value.ToString().Trim() != "")
                    {
                        cell          = new JZTestCell();
                        cell.Name     = JZTestEnum.LDZDL;
                        cell.CellName = SheetView2.Cells[i, 4].Value.ToString();
                        cell.SheetID  = new Guid(SheetView2.Cells[i, 4].Tag.ToString());
                        c.Config.Add(cell);
                    }
                    rowCell = SheetView2.Cells[i, 6];
                    if (rowCell.Value != null && rowCell.Value.ToString().Trim() != "")
                    {
                        cell          = new JZTestCell();
                        cell.Name     = JZTestEnum.DHBJ;
                        cell.CellName = SheetView2.Cells[i, 6].Value.ToString();
                        cell.SheetID  = new Guid(SheetView2.Cells[i, 6].Tag.ToString());
                        c.Config.Add(cell);
                    }
                    list.Add(c);
                }
            }

            String json = Newtonsoft.Json.JsonConvert.SerializeObject(list);

            ModuleHelperClient.UpdateModuleConfigInfo(moduleID, json, cb_active.Checked, deviceType);
            staParent.BindModelList();
            this.Close();
        }