Ejemplo n.º 1
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_add_Click(object sender, EventArgs e)
 {
     using (CompanyChange dialog = new CompanyChange())
     {
         dialog.ChangeTitle = "新增单位";
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             UserModule module = dialog.GetModule;
             module.PassWord = "******";
             SqliteHelper.Insert(TableName.User, module, out string msg);
             if (!string.IsNullOrEmpty(msg))
             {
                 MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 return;
             }
             DataRefresh();
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void RowUpdateClick(object sender, DataGridViewCellEventArgs e)
        {
            string     name      = ((DataGridView)sender).CurrentRow.Cells["UserName"].Value.ToString();
            UserModule preModule = null;

            foreach (var item in users)
            {
                if (item.UserName == name)
                {
                    preModule = item;
                    break;
                }
            }
            if (preModule == null)
            {
                return;
            }
            using (CompanyChange dialog = new CompanyChange(preModule))
            {
                dialog.ChangeTitle = "修改单位信息";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    UserModule currentUser = dialog.GetModule;
                    currentUser.PassWord = preModule.PassWord;
                    SqliteHelper.Update(TableName.User, 0, currentUser, out string msg);
                    if (string.IsNullOrEmpty(msg))
                    {
                        DataRefresh();
                    }
                    else
                    {
                        MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }