Esempio n. 1
0
        private void button_select_Click(object sender, EventArgs e)
        {
            Button  button = sender as Button;
            ListBox listFrom = listBox_right, listTo = listBox_left;

            if (button.Name.Equals("button_right"))
            {
                listFrom = listBox_left;
                listTo   = listBox_right;
            }

            for (int i = 0; i < listFrom.SelectedItems.Count; i++)
            {
                CharactorValue menu = (CharactorValue)listFrom.SelectedItems[i];
                listTo.Items.Add(menu);
            }
            for (int i = listFrom.SelectedItems.Count - 1; i >= 0; i--)
            {
                CharactorValue menu = (CharactorValue)listFrom.SelectedItems[i];
                listFrom.Items.Remove(menu);
            }

            if (selectValueChanged != null)
            {
                selectValueChanged.Invoke();
            }
        }
Esempio n. 2
0
        public int Update(CharactorValue info)
        {
            string commandText = string.Format("update CharactorValue set name='{0}' where ID={1}",
                                               info.Name, info.Id);

            return(DbHelperAccess.executeNonQuery(commandText));
        }
Esempio n. 3
0
 public void setSelectItems(List <CharactorValue> cvs)
 {
     foreach (CharactorValue cv in cvs)
     {
         CharactorValue value = getValue(cv.Id);
         if (value != null)
         {
             this.listBox_left.Items.Remove(value);
             this.listBox_right.Items.Add(value);
         }
     }
 }
Esempio n. 4
0
 public int Insert(CharactorValue info)
 {
     try
     {
         string commandText = string.Format("insert into CharactorValue(name, charactorID) values('{0}', {1})", info.Name, info.CharactorId);
         DbHelperAccess.executeNonQuery(commandText);
         int id = DbHelperAccess.executeMax("ID", "CharactorValue");
         return(id);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
        private void button_save_Click(object sender, EventArgs e)
        {
            if (this.needSave == true)
            {
                //List<CharactorValue> values = new List<CharactorValue>();
                foreach (DataGridViewRow row in this.dataGridView1.Rows)
                {
                    CharactorValue value = new CharactorValue();
                    string         name  = null;
                    if (ValidateUtility.getString(row.Cells["name"], true, out name) == false)
                    {
                        return;
                    }
                    value.Name        = name;
                    value.CharactorId = charactorId;

                    object id = row.Cells["ID"].Value;
                    if (id == null || id.ToString() == "")
                    {
                        value.Id = -1;
                        int idReturn = CharactorValueDao.getInstance().Insert(value);
                        row.Cells["ID"].Value = idReturn;
                    }
                    else
                    {
                        value.Id = int.Parse(id.ToString());
                        CharactorValueDao.getInstance().Update(value);
                    }

                    //values.Add(value);
                }

                /*
                 * foreach (CharactorValue value in values) {
                 *  if (value.Id <= 0)
                 *      CharactorValueDao.getInstance().Insert(value);
                 *  else
                 *      CharactorValueDao.getInstance().Update(value);
                 * }*/

                this.modify = true;

                this.needSave            = false;
                this.button_save.Enabled = false;

                MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Esempio n. 6
0
        public CharactorValue findById(int charactorValueID)
        {
            string commandText = "select * from CharactorValue where ID = " + charactorValueID.ToString();

            DataRow        dr = DbHelperAccess.executeQueryGetOneRow(commandText);
            CharactorValue cv = new CharactorValue();

            if (dr != null)
            {
                cv.Id          = (int)dr["ID"];
                cv.CharactorId = (int)dr["charactorID"];
                cv.Name        = dr["name"] as string;
            }

            return(cv);
        }
Esempio n. 7
0
        public List <CharactorValue> FindList(int charactorID)
        {
            string commandText = "select * from CharactorValue where charactorID = " + charactorID.ToString();

            DataTable             dt       = DbHelperAccess.executeQuery(commandText);
            List <CharactorValue> elements = new List <CharactorValue>();

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    CharactorValue element = new CharactorValue();
                    element.Id          = (int)dr["ID"];
                    element.Name        = dr["name"] as string;
                    element.CharactorId = (int)dr["charactorID"];
                    elements.Add(element);
                }
            }

            return(elements);
        }