Example #1
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     Models.testdata selectedRow = (Models.testdata)grvData.CurrentRow.DataBoundItem;
     database.Table(typeof(Models.testdata)).Delete(selectedRow);
     MessageBox.Show("Delete successfully. Refresh...");
     loadData();
 }
Example #2
0
        public testdata(Models.testdata entity)
        {
            InitializeComponent();
            regisEvents();
            initial(entity);
            isUpdate = true;
			this.Text = "UpdateForm";
        }
Example #3
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     if (grvData.CurrentRow == null)
     {
         return;
     }
     Models.testdata selectedRow = (Models.testdata)grvData.CurrentRow.DataBoundItem;
     Views.testdata  updateForm  = new Views.testdata(selectedRow);
     updateForm.Show();
 }
Example #4
0
        private void initial(Models.testdata entity)
        {
			itnumericupdownrowID1.Text = entity.rowID;
			itnumericupdownbyte12.Text = entity.byte1;
			itnumericupdownshort13.Text = entity.short1;
			itnumericupdownint14.Text = entity.int1;
			itnumericupdownlong15.Text = entity.long1;
			ittextboxfloat16.Text = entity.float1;
			itnumericupdowndouble17.Value = Decimal.Parse(entity.double1.ToString();
			itnumericupdowndecimal18.Value = Decimal.Parse(entity.decimal1.ToString();
			itnumericupdownmoney19.Value = Decimal.Parse(entity.money1.ToString();
			ittextboxstring110.Text = entity.string1;
			ittextboxbinary111.Text = entity.binary1;
			ittextboximage112.Text = entity.image1;
			bool1.Checked = entity.bool1;
			itdatetimepickerdatetime114.Text = entity.datetime1;
			ittextboxguid115.Text = entity.guid1;

			  database = new MSSQLDatabase(new System.Data.SqlClient.SqlConnection(connstring));
        }
Example #5
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();
            }
        }