Ejemplo n.º 1
0
        protected void bt_Save_Click(object sender, EventArgs e)
        {
            lb_Error.Text = "";
            if (!string.IsNullOrEmpty(tb_RoomCode.Text.Trim()))
            {
                CY.GFive.Core.Business.RoomInfo ri = CY.GFive.Core.Business.RoomInfo.GetByCode(tb_RoomCode.Text.Trim());
                if (ri != null)
                {
                    lb_Error.Text = "已存在本编号的寝室!";
                    return;
                }
            }
            if (!string.IsNullOrEmpty(tb_BuildingCode.Text.Trim()) && !string.IsNullOrEmpty(tb_RoomNum.Text.Trim()))
            {
                CY.GFive.Core.Business.RoomInfo checkri = CY.GFive.Core.Business.RoomInfo.GetByBuildAndNo(tb_BuildingCode.Text.Trim(), tb_RoomNum.Text.Trim());
                if (checkri != null)
                {
                    lb_Error.Text = "本楼已存在相同寝室号的寝室";
                    return;
                }
            }
            try
            {
                RoomInfo ri = new RoomInfo();
                ri.RoomCode = tb_RoomCode.Text;
                ri.BuildingCode = tb_BuildingCode.Text;
                ri.RoomNum = tb_RoomNum.Text;
                ri.TotalNum = Convert.ToInt32(tb_TotalNum.Text);
                //ri.ExistNum = Convert.ToInt32(tb_ExistNum.Text);
                ri.RoomState = ddlRoomState.SelectedValue;

                ri.Save();
                lb_Error.Text = "添加成功";
                tb_BuildingCode.Text = "";
                tb_RoomCode.Text = "";
                tb_RoomNum.Text = "";
                tb_TotalNum.Text = "";
                tb_ExistNum.Text = "";
            }
            catch (Exception ex)
            {
                lb_Error.Text = "错误信息:" + ex.Message;

                tb_BuildingCode.Text = "";
                tb_RoomCode.Text = "";
                tb_RoomNum.Text = "";
                tb_TotalNum.Text = "";
                tb_ExistNum.Text = "";
            }
        }