예제 #1
0
 private void Btn_Cancel_Click(object sender, RoutedEventArgs e)
 {
     getTableData();
     TBid.Clear();
     TBname.Clear();
     TBPass.Clear();
     Region.SelectedItem = new KeyValuePair <int, string>(0, "请选择仓库");
 }
 private void ConfirmButton_Click(object sender, RoutedEventArgs e)
 {
     TBid.GetBindingExpression(TextBox.TextProperty).UpdateSource();
     if (ColorPicker.SelectedColor == null)
     {
         _colorError           = true;
         ColorError.Visibility = Visibility.Visible;
     }
     if (_errCount == 0 && !_colorError)
     {
         newTag.Color = (Color)ColorPicker.SelectedColor;
         _mainWindow.Tags.Add(newTag);
         this.Close();
     }
 }
예제 #3
0
        /// <summary>
        /// 写入数据库
        /// </summary>
        public void inputDB()
        {
            try
            {
                string sql = "";
                string id_staff, name_staff, pass_staff, role_staff, Region_staff;

                DataSet ds = new DataSet();

                Region_staff = Region.SelectedValue.ToString();
                if (Region_staff.Equals("0"))
                {
                    MessageBox.Show("请选择所在网点");
                    return;
                }
                //Id = BaseClass.getInsertMaxId("T_Weight", "Id", "000001");

                if (TBid.Text != "")
                {
                    id_staff = TBid.Text;
                }
                else
                {
                    id_staff = "";
                    MessageBox.Show("请输入员工编号");
                    return;
                }

                if (TBname.Text != "")
                {
                    name_staff = TBname.Text;
                }
                else
                {
                    name_staff = "";
                    MessageBox.Show("请输入员工姓名");
                    return;
                }


                if (TBPass.Text != "")
                {
                    pass_staff = TBPass.Text;
                }
                else
                {
                    pass_staff = "";
                    MessageBox.Show("请输入密码");
                    return;
                }

                sql = "select * from t_staff as t1 where t1.id_staff = '" + id_staff + "'";
                ds  = DBClass.execQuery(sql);
                if (ds.Tables[0].Rows.Count > 0)
                {
                    sql = "update T_Staff set name_staff = '{1}', pass_staff = '{2}', " +
                          "role_staff = '{3}', region_staff = '{4}' " +
                          "where id_staff = '{0}'";
                }
                else
                {
                    sql = "insert into T_Staff " +
                          "(id_staff, name_staff, pass_staff, role_staff, Region_staff) " +
                          "values ('{0}','{1}','{2}','{3}','{4}')";
                }

                role_staff = "1";

                sql = string.Format(sql, id_staff, name_staff, pass_staff, role_staff, Region_staff);
                int n = DBClass.execUpdate(sql);
                if (n > 0)
                {
                    MessageBox.Show("保存成功!");
                    TBid.Clear();
                    TBname.Clear();
                    TBPass.Clear();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("操作失败。请重试" + e.Message);
            }
        }