コード例 #1
0
ファイル: Hotelfrm.cs プロジェクト: thaimoc/ETour
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            DialogResult dlg = MessageBox.Show("Do you want to update this hotel?", "Kim Nguyen say:", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (dlg == System.Windows.Forms.DialogResult.Yes)
            {
                if (KhachSan.Update(controls_Load()))
                {
                    if (listf.Count > 0)
                    {
                        foreach (var item in listf)
                        {
                            KSanDLich ks = new KSanDLich();
                            ks.MKS     = Code;
                            ks.MDiemDL = item;
                            if (!KSanDLich.Add(ks))
                            {
                                MessageBox.Show(String.Format("Updating had been failse with the scenic witch had been code {0}?", item), "Kim Nguyen say:", MessageBoxButtons.OK, MessageBoxIcon.Question);
                            }
                        }
                    }
                    MessageBox.Show("Updating is successful?", "Kim Nguyen say:", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                }
                else
                {
                    MessageBox.Show("Updating had been failse?", "Kim Nguyen say:", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
            }
        }
コード例 #2
0
ファイル: Hotelfrm.cs プロジェクト: thaimoc/ETour
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (clbright.Items.Count <= 0)
            {
                MessageBox.Show("You do not choose the Sinics Witch are had been saved by this hotels!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (KhachSan.FindByName(txtName.Text, txtAddress.Text).Count > 0)
            {
                MessageBox.Show("This the hotel had been exited! Try again!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtName.Focus();
                return;
            }

            KhachSan ks = controls_Load();
            int      id = KhachSan.Add(ks);

            if (id > 0)
            {
                MessageBox.Show("Adding is sucessful!", "Kim Nguyen Say", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                //Khu vực thêm các KSanDLich
                for (int i = 0; i < clbright.Items.Count; i++)
                {
                    KSanDLich rs = new KSanDLich();
                    rs.MKS = id;
                    string[] s = clbright.Items[i].ToString().Split(' ');
                    rs.MDiemDL = MyConvert.ToInt32(s[0]);
                    KSanDLich.Add(rs);
                }
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                return;
            }
            else
            {
                MessageBox.Show("Adding had been failse!", "Kim Nguyen Say", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }