コード例 #1
0
ファイル: Save.cs プロジェクト: sadikaiub/238166
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                mobile.ModelName = modelNameTextBox.Text;
                mobile.Imei      = imeiTextBox.Text;
                mobile.Price     = Convert.ToInt32(priceTextBox.Text);
                if (imeiTextBox.Text.Length <= 15)
                {
                    MessageBox.Show("IMEI must be exact 15 Character !");
                    return;
                }
                int isExecuted;
                isExecuted = _mobileManager.Insert(mobile);

                if (isExecuted > 0)
                {
                    MessageBox.Show("Saved!!");
                }
                else
                {
                    MessageBox.Show("Not saved!!");
                }
            }

            catch (Exception exception)
            {
                MessageBox.Show("Exception!");
            }
            // _mobileManager.Insert(mobile);
        }
コード例 #2
0
ファイル: MobileSaveForm.cs プロジェクト: TajdikAhamed/237511
        private void SaveButton_Click(object sender, EventArgs e)
        {
            Mobile mobile = new Mobile();

            mobile.Name  = nameTextBox.Text;
            mobile.IMEI  = IMEITextBox.Text;
            mobile.Price = Convert.ToDouble(PriceTextBox.Text);

            _mobileManager.Insert(mobile);
        }
コード例 #3
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (IMEITextBox.Text.Equals("") && IMEITextBox.Text.Length != 15)
                {
                    MessageBox.Show("Invalid Input!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    bool IsExistsIMEi = _mobileManager.IsExists(IMEITextBox.Text);
                    if (IsExistsIMEi)
                    {
                        MessageBox.Show("IMEI Exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }

                if (IMEITextBox.Text.Length != 15)
                {
                    MessageBox.Show("IMEI Number Must be 15 digit!", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                    return;
                }

                if (nameTextBox.Text.Equals(""))
                {
                    MessageBox.Show("Invalid Name Input!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (PriceTextBox.Text.Equals(""))
                {
                    MessageBox.Show("Invalid Price Input!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }



                Mobile mobile = new Mobile();
                mobile.Name  = nameTextBox.Text;
                mobile.IMEI  = IMEITextBox.Text;
                mobile.Price = Convert.ToDouble(PriceTextBox.Text);

                _mobileManager.Insert(mobile);

                button1_Click(sender, e);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }