天天看点

【机房重构】修改基础数据

UI层

namespace UI
{
    public partial class ModifyBasicData : Form
    {
        public ModifyBasicData()
        {
            InitializeComponent();
        }

        private void ButModifyData_Click(object sender, EventArgs e)
        {
            Login login = new Login();
            if (TxtUnitCash.Text.Trim() == "")
            {
                MessageBox.Show("单价不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (TxtVIP.Text.Trim() == "")
            {
                MessageBox.Show("VIP单价不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (TxtUnitTime.Text.Trim() == "")
            {
                MessageBox.Show("单位时间不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (TxtLeastTime.Text.Trim() == "")
            {
                MessageBox.Show("最小上机时间不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (TxtLeastCash.Text.Trim() =="")
            {
                MessageBox.Show("最小充值金额不能为空", "温馨提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            Facade.ModifyBasicDataFacade facade = new Facade.ModifyBasicDataFacade();
            Entity.BasicData_Info BasicDataInfo = new Entity.BasicData_Info();

            BasicDataInfo.UnitCash = TxtUnitCash.Text.Trim();
            BasicDataInfo.VIPUnitCash = TxtVIP.Text.Trim();
            BasicDataInfo.UnitTime = TxtUnitTime.Text.Trim();
            BasicDataInfo.LeastCash = TxtLeastCash.Text.Trim();
            BasicDataInfo.LeastTime = TxtLeastTime.Text.Trim();
            BasicDataInfo.Head = Login.UserID;
            BasicDataInfo.Date = DateTime.Now;

            Facade.ModifyBasicDataFacade facadeModify = new Facade.ModifyBasicDataFacade();
            int  intModify = facadeModify.ModifyData(BasicDataInfo);
            MessageBox.Show("修改成功");

        }

        private void ModifyBasicData_Load(object sender, EventArgs e)
        {
            Entity.BasicData_Info BasicDataInfo = new Entity.BasicData_Info();
            Facade.ModifyBasicDataFacade facade = new Facade.ModifyBasicDataFacade();
            DataTable dt = facade.InquiryBasicData(BasicDataInfo);

            TxtUnitCash.Text = dt.Rows[0]["UnitCash"].ToString();
            TxtVIP.Text = dt.Rows[0]["VIPUnitCash"].ToString();
            TxtUnitTime.Text = dt.Rows[0]["UnitTime"].ToString();
            TxtLeastTime.Text = dt.Rows[0]["LeastTime"].ToString();
            TxtLeastCash.Text = dt.Rows[0]["LeastCash"].ToString();
            TxtHead.Text = dt.Rows[0]["Head"].ToString();
            TxtDate.Text = dt.Rows[0]["Date"].ToString();
            
        }
    }
}
           

界面展示

【机房重构】修改基础数据

总结

其它层的代码和前面介绍的一些功能的代码如出一辙,再次不再过多的介绍。另外通过做这个功能,体会到了一个道理,界面的设计师越简单越好,简单的界面,用户用着也顺心,后端代码也比较好写,减少了很多不必要的繁琐。