예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string rowID = itnumericupdownrowID1.Text;
                string byte1 = itnumericupdownbyte12.Text;
                string short1 = itnumericupdownshort13.Text;
                string int1 = itnumericupdownint14.Text;
                string long1 = itnumericupdownlong15.Text;
                string float1 = ittextboxfloat16.Text;
                string double1 = Int32.Parse(itnumericupdowndouble17.Value.ToString());
                string decimal1 = Int32.Parse(itnumericupdowndecimal18.Value.ToString());
                string money1 = Int32.Parse(itnumericupdownmoney19.Value.ToString());
                string string1 = ittextboxstring110.Text;
                string binary1 = ittextboxbinary111.Text;
                string image1 = ittextboximage112.Text;
                bool bool1 = itcheckboxbool113.Checked;
                string datetime1 = itdatetimepickerdatetime114.Text;
                string guid1 = ittextboxguid115.Text;

                // add
                if (!isUpdate)
                {
                    Models.testdata tmp = new  Models.testdata();
                    tmp.rowID = rowID;
                    tmp.byte1 = byte1;
                    tmp.short1 = short1;
                    tmp.int1 = int1;
                    tmp.long1 = long1;
                    tmp.float1 = float1;
                    tmp.double1 = double1;
                    tmp.decimal1 = decimal1;
                    tmp.money1 = money1;
                    tmp.string1 = string1;
                    tmp.binary1 = binary1;
                    tmp.image1 = image1;
                    tmp.bool1 = bool1;
                    tmp.datetime1 = datetime1;
                    tmp.guid1 = guid1;

                    database.Table(typeof(Models.testdata)).Insert(tmp);
                }
                // update
                else
                {
                    Models.testdata tmp = new  Models.testdata();
                    tmp.rowID = rowID;
                    tmp.byte1 = byte1;
                    tmp.short1 = short1;
                    tmp.int1 = int1;
                    tmp.long1 = long1;
                    tmp.float1 = float1;
                    tmp.double1 = double1;
                    tmp.decimal1 = decimal1;
                    tmp.money1 = money1;
                    tmp.string1 = string1;
                    tmp.binary1 = binary1;
                    tmp.image1 = image1;
                    tmp.bool1 = bool1;
                    tmp.datetime1 = datetime1;
                    tmp.guid1 = guid1;

                    database.Table(typeof(Models.testdata)).Update(tmp);
                }
            }
            catch(InvalidCastException ex)
            {
                Debug.WriteLine(ex.Message);
                MessageBox.Show("Invalid value for type Number! Please try again.");
                this.Close();
            }
        }