⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.cs

📁 航运管理系统
💻 CS
📖 第 1 页 / 共 2 页
字号:
                MessageBox.Show("不可直接在显示窗体中添加信息,只允许修改及删除!");
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            adap = db.getAdapter("bill");
            string delBill = "delete from 清单 where 提单号=@number";
            adap.DeleteCommand = new SqlCommand(delBill, conn);

            sp = adap.DeleteCommand.Parameters.Add("@number", SqlDbType.Char);
            sp.SourceColumn = "提单号";
            sp.SourceVersion = DataRowVersion.Original;

            dr = MessageBox.Show("您确定要删除当前纪录么?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                ds.Tables[2].Rows[dataGridView2.CurrentRow.Index].Delete();
                adap.Update(ds, "清单管理");
                MessageBox.Show("已删除纪录!");
            }
            else
            {
                MessageBox.Show("删除失败!");
                return;
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                conn.Open();
                String insShip = "insert into 船舶 values('" + textBox23.Text + "','" + textBox21.Text + "','" + textBox26.Text + "','" + textBox25.Text + "','" + textBox15.Text + "','" + textBox24.Text + "')";
                comm = new SqlCommand(insShip, conn);
                int result = comm.ExecuteNonQuery();
                if (result == 1)
                {
                    MessageBox.Show("添加纪录成功!");
                    sql = "select * from 船舶 where 船号='" + textBox23.Text + "'";
                    ds = db.search(sql, "ship");
                    dataGridView3.Update();
                }
                else
                {
                    MessageBox.Show("添加纪录失败!");
                }
                
            }
            catch (SqlException)
            {                
                MessageBox.Show("请检验数据格式是否正确!");
            }
            conn.Close();
        }

        private void button11_Click(object sender, EventArgs e)
        {
            string updShip = "update 船舶 set 船舶中文名=@chinese,船舶英文名=@english,船舶类型=@type,载货吨=@tonnage,主机马力=@horsepower where 船号=@number";
            adap = db.getAdapter("ship");
            adap.UpdateCommand = new SqlCommand(updShip, conn);

            sp = adap.UpdateCommand.Parameters.Add("@chinese", SqlDbType.Char);
            sp.SourceColumn = "船舶中文名";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@english", SqlDbType.VarChar);
            sp.SourceColumn = "船舶英文名";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@type", SqlDbType.VarChar);
            sp.SourceColumn = "船舶类型";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@tonnage", SqlDbType.VarChar);
            sp.SourceColumn = "载货吨";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@horsepower", SqlDbType.VarChar);
            sp.SourceColumn = "主机马力";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@number", SqlDbType.VarChar);
            sp.SourceColumn = "船号";
            sp.SourceVersion = DataRowVersion.Current;
            try
            {
                if (ds.HasChanges())
                {
                    dr = MessageBox.Show("您想要保存这些修改么?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.No)
                        return;
                    else
                    {
                        adap.Update(ds, "船舶管理");
                        MessageBox.Show("数据库已更新!");
                    }
                }
                else
                {
                    MessageBox.Show("数据库未做任何修改!");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("不可直接在显示窗体中添加信息,只允许修改及删除!");
            }
        }

        private void button12_Click(object sender, EventArgs e)
        {
            string delShip = "delete from 船舶 where 船号=@number";
            adap = db.getAdapter("ship");
            adap.DeleteCommand = new SqlCommand(delShip, conn);

            sp = adap.DeleteCommand.Parameters.Add("@number", SqlDbType.Char);
            sp.SourceColumn = "船号";
            sp.SourceVersion = DataRowVersion.Original;

            dr = MessageBox.Show("您确定要删除当前纪录么?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                ds.Tables[1].Rows[dataGridView3.CurrentRow.Index].Delete();
                adap.Update(ds, "船舶管理");
                MessageBox.Show("已删除纪录!");
            }
            else
            {
                MessageBox.Show("删除失败!");
                return;
            }
        }

        private void label2_MouseMove(object sender, MouseEventArgs e)
        {
            this.Cursor = Cursors.Hand;
        }

        private void mainFrame_FormClosing(object sender, FormClosingEventArgs e)
        {
            Application.Exit();
        }

        private void button13_Click(object sender, EventArgs e)
        {
            sql = "select * from 货主 where 序号='" + textBox10.Text + "'";
            ds = db.index(sql, "customer");
            dataGridView4.DataSource = ds.Tables["货主"].DefaultView;
            textBox10.Text = null;
            dataGridView4.Visible = true;
        }

        private void button14_Click(object sender, EventArgs e)
        {
            sql = "select * from 清单 where 提单号='" + textBox27.Text + "'";
            ds = db.index(sql, "bill");
            dataGridView4.DataSource = ds.Tables["清单"].DefaultView;
            textBox27.Text = null;
            dataGridView4.Visible = true;
        }

        private void button15_Click(object sender, EventArgs e)
        {
            sql = "select * from 船舶 where 船号='" + textBox28.Text + "'";
            ds = db.index(sql, "ship");
            dataGridView4.DataSource = ds.Tables["船舶"].DefaultView;
            textBox28.Text = null;
            dataGridView4.Visible = true;
        }

        private void button19_Click(object sender, EventArgs e)
        {
            sql = "select * from 班轮船期 where 航次='" + textBox39.Text + "'";
            ds = db.index(sql, "date");
            dataGridView4.DataSource = ds.Tables["船期"].DefaultView;
            textBox39.Text = null;
            dataGridView4.Visible = true;
        }     

        private void label2_MouseLeave(object sender, EventArgs e)
        {
            this.Cursor = Cursors.Default;
        }

        private void button17_Click(object sender, EventArgs e)
        {
            string updShip = "update 班轮船期 set 船号=@shipNumber,结单日=@recept,开船日=@start,卸序港=@port,装船地=@ground,场站=@stop,入港清单联系人=@person,入港时间=@time,订舱联系人=@people where 航次=@number";
            adap = db.getAdapter("date");
            adap.UpdateCommand = new SqlCommand(updShip, conn);

            sp = adap.UpdateCommand.Parameters.Add("@number", SqlDbType.Char);
            sp.SourceColumn = "航次";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@people", SqlDbType.VarChar);
            sp.SourceColumn = "订舱联系人";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@time", SqlDbType.VarChar);
            sp.SourceColumn = "入港时间";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@person", SqlDbType.VarChar);
            sp.SourceColumn = "入港清单联系人";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@stop", SqlDbType.VarChar);
            sp.SourceColumn = "场站";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@ground", SqlDbType.VarChar);
            sp.SourceColumn = "装船地";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@port", SqlDbType.VarChar);
            sp.SourceColumn = "卸序港";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@start", SqlDbType.VarChar);
            sp.SourceColumn = "开船日";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@recept", SqlDbType.VarChar);
            sp.SourceColumn = "结单日";
            sp.SourceVersion = DataRowVersion.Current;

            sp = adap.UpdateCommand.Parameters.Add("@shipNumber", SqlDbType.VarChar);
            sp.SourceColumn = "船号";
            sp.SourceVersion = DataRowVersion.Current;
            
            try
            {
                if (ds.HasChanges())
                {
                    dr = MessageBox.Show("您想要保存这些修改么?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (dr == DialogResult.No)
                        return;
                    else
                    {
                        adap.Update(ds, "班轮船期");
                        MessageBox.Show("数据库已更新!");
                    }
                }
                else
                {
                    MessageBox.Show("数据库未做任何修改!");
                }
            }
            catch (Exception ee)
            {
                MessageBox.Show("不可直接在显示窗体中添加信息,只允许修改及删除!");
                Console.WriteLine(ee.Message);
            }
        }

        private void button18_Click(object sender, EventArgs e)
        {
            try
            {
                conn.Open();
                String insShip = "insert into 班轮船期 values('" + textBox31.Text + "','" + textBox32.Text + "','" + textBox33.Text + "','" + textBox35.Text + "','" + textBox30.Text + "','" + textBox29.Text + "','" + textBox34.Text + "','" + textBox36.Text + "','" + textBox37.Text + "','" + textBox38.Text + "')";
                comm = new SqlCommand(insShip, conn);
                int result = comm.ExecuteNonQuery();
                if (result == 1)
                {
                    MessageBox.Show("添加纪录成功!");
                    sql = "select * from 班轮船期 where 航次='" + textBox31.Text + "'";
                    ds = db.search(sql, "date");
                    dataGridView5.Update();
                }
                else
                {
                    MessageBox.Show("添加纪录失败!");
                }

            }
            catch (SqlException)
            {
                MessageBox.Show("请检验数据格式是否正确!");
            }
            conn.Close();
        }

        private void button16_Click(object sender, EventArgs e)
        {
            string delShip = "delete from 班轮船期 where 航次=@number";
            adap = db.getAdapter("date");
            adap.DeleteCommand = new SqlCommand(delShip, conn);

            sp = adap.DeleteCommand.Parameters.Add("@number", SqlDbType.Char);
            sp.SourceColumn = "航次";
            sp.SourceVersion = DataRowVersion.Original;

            dr = MessageBox.Show("您确定要删除当前纪录么?", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
            if (dr == DialogResult.Yes)
            {
                ds.Tables[3].Rows[dataGridView5.CurrentRow.Index].Delete();
                adap.Update(ds, "班轮船期");
                MessageBox.Show("已删除纪录!");
            }
            else
            {
                MessageBox.Show("删除失败!");
                return;
            }
        }

                           
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -