//保存数据 private bool saveData() { int type = 2; if (!string.IsNullOrEmpty(ViewState["ComputerDetailType"].ToString())) { type = int.Parse(ViewState["ComputerDetailType"].ToString()); } string sqlStr = string.Empty; if (type == 1)//修改 { sqlStr = "update COMPUTER_ROOM set " + " ORG_ID =" + hfOrgID.Value + " ," + "COMPUTER_ROOM_NAME='" + txtCOMPUTER_ROOM_NAME.Text + "'," + "ADDRESS='" + txtADDRESS.Text + "'," + "COMPUTER_NUMBER=" + txtCOMPUTER_NUMBER.Text + "," + "BAD_SEAT='" + hfBadSeatIDs.Value + "'," + "IS_EFFECT= " + ddlIS_EFFECT.SelectedValue + "," + "Contract_Person='" + txtContractPerson.Text.Trim() + "'," + "Contract_Phone='" + txtContractPhone.Text.Trim() + "'," + "COMPUTER_SERVER_ID = " + (dropServer.SelectedValue == "" ? "null" : dropServer.SelectedValue) + " where COMPUTER_ROOM_ID=" + ViewState["ComputerDetailID"]; } else if (type == 2) //新增 { sqlStr = "insert into Computer_room values (COMPUTER_ROOM_SEQ.nextval," + hfOrgID.Value + ", '" + txtCOMPUTER_ROOM_NAME.Text + "','" + txtADDRESS.Text + "'," + txtCOMPUTER_NUMBER.Text + ",'" + hfBadSeatIDs.Value + "'," + ddlIS_EFFECT.SelectedValue + "," + (dropServer.SelectedValue == ""?"null":dropServer.SelectedValue) + ",'" + txtContractPerson.Text.Trim() + "','" + txtContractPhone.Text.Trim() + "',0)"; } OracleAccess ora = new OracleAccess(); try { ora.ExecuteNonQuery(sqlStr); if (ddlIS_EFFECT.SelectedValue == "0" && type == 1) { sqlStr = "delete from COMPUTER_ROOM_DETAIL where COMPUTER_ROOM_ID=" + ViewState["ComputerDetailID"]; ora.ExecuteNonQuery(sqlStr); } } catch { OxMessageBox.alert(this, "编辑失败!"); return(false); } ViewState["ComputerDetailType"] = 1; //设置为编辑 return(true); }
/// <summary> /// 判断是否有空 /// </summary> /// <returns></returns> private bool isHaveNull() { if (string.IsNullOrEmpty(hfOrgID.Value)) { OxMessageBox.alert(this, "请选择组织机构!"); return(true); } if (string.IsNullOrEmpty(txtCOMPUTER_ROOM_NAME.Text)) { OxMessageBox.alert(this, "请填写微机教室名!"); return(true); } if (string.IsNullOrEmpty(txtCOMPUTER_NUMBER.Text)) { OxMessageBox.alert(this, "请填写机位数!"); return(true); } if (string.IsNullOrEmpty(dropServer.SelectedValue)) { OxMessageBox.alert(this, "请选择微机教室服务器!"); return(true); } int num = 0; if (txtCOMPUTER_NUMBER.Text.Length > 3 || !int.TryParse(txtCOMPUTER_NUMBER.Text, out num)) { OxMessageBox.alert(this, "请填写正确的机位数!"); return(true); } if (ddlIS_EFFECT.SelectedValue == "2") { OxMessageBox.alert(this, "请选择是否有效!"); return(true); } if (!string.IsNullOrEmpty(this.txtCOMPUTER_NUMBER.Text.Trim().ToString()) && !string.IsNullOrEmpty(this.txtBAD_SEAT.Text.Trim().ToString())) { int allcount = int.Parse(this.txtCOMPUTER_NUMBER.Text.Trim().ToString()); int badCount = this.txtBAD_SEAT.Text.Trim().ToString().Split(',').Length; if (badCount > allcount) { OxMessageBox.alert(this, "损坏机位数不能大于总机位数,请重新填写!"); return(true); } } return(false); }