Ejemplo n.º 1
0
 public void Add(DataLayer.Model.UserSetting model)
 {
     this.Clear();
     using (var context = new DataLayer.DAL.MyDBContext())
     {
         context.UserSetting.Add(model);
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 private void btnSelectOK_Click(object sender, System.EventArgs e)
 {
     var model = userSettingBLL.GetFirstModel();
     if (null == model)
     {
         model = new DataLayer.Model.UserSetting();
     }
     DataLayer.Model.FileReplaceSetting setting = null;
     if (!string.IsNullOrEmpty(model.FileReplaceSetting))
     {
         setting = XCLNetTools.Serialize.JSON.DeSerialize<DataLayer.Model.FileReplaceSetting>(model.FileReplaceSetting);
     }
     if (null == setting)
     {
         setting = new DataLayer.Model.FileReplaceSetting();
     }
     //获取已选行
     setting.RuleConfigIds = new List<int>();
     var selectedRows = this.dataGridRuleConfig.SelectedRows;
     if (null != selectedRows && selectedRows.Count > 0)
     {
         for (int i = 0; i < selectedRows.Count; i++)
         {
             var currentData = selectedRows[i].DataBoundItem as DataLayer.Model.FileReplace_RuleConfig;
             if (null != currentData)
             {
                 setting.RuleConfigIds.Add(currentData.RuleConfigID);
             }
         }
     }
     model.FileReplaceSetting = XCLNetTools.Serialize.JSON.Serialize(setting);
     userSettingBLL.Add(model);
     //刷新父窗体数据
     if (null != _mainForm)
     {
         _mainForm.InitCurrentRuleList();
     }
     this.Close();
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 选好了
        /// </summary>
        private void btnSelectOK_Click(object sender, System.EventArgs e)
        {
            var model = userSettingBLL.GetFirstModel();

            if (null == model)
            {
                model = new DataLayer.Model.UserSetting();
            }
            DataLayer.Model.FileReplaceSetting setting = null;
            if (!string.IsNullOrEmpty(model.FileReplaceSetting))
            {
                setting = XCLNetTools.Serialize.JSON.DeSerialize <DataLayer.Model.FileReplaceSetting>(model.FileReplaceSetting);
            }
            if (null == setting)
            {
                setting = new DataLayer.Model.FileReplaceSetting();
            }
            //获取已选行
            setting.RuleConfigIds = new List <int>();
            var selectedRows = this.dataGridRuleConfig.GetSelectedRows();

            if (null != selectedRows && selectedRows.Length > 0)
            {
                for (int i = 0; i < selectedRows.Length; i++)
                {
                    var currentData = this.dataGridRuleConfig.GetDataRow(selectedRows[i]);
                    if (null != currentData)
                    {
                        setting.RuleConfigIds.Add(XCLNetTools.Common.DataTypeConvert.ToInt(currentData["RuleConfigID"]));
                    }
                }
            }
            model.FileReplaceSetting = XCLNetTools.Serialize.JSON.Serialize(setting);
            userSettingBLL.Add(model);
            this.Close();
        }