//保存数据
        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);
        }
 private void deleteStudent()
 {
     try
     {
         string[]     strArry = hidStudent.Value.Split('|');
         OracleAccess access  = new OracleAccess();
         string       sql     = string.Format("update zj_train_plan_employee set train_class_id=null  where train_plan_employee_id={0}",
                                              Convert.ToInt32(strArry[1]));
         access.ExecuteNonQuery(sql);
     }
     catch
     {
         OxMessageBox.MsgBox3("数据删除失败!");
     }
 }
Exemple #3
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string       argument = Request.Form["__EVENTARGUMENT"];
            OracleAccess ora      = new OracleAccess();

            try
            {
                ora.ExecuteNonQuery("delete COMPUTER_ROOM_APPLY where COMPUTER_ROOM_APPLY_ID=" + argument);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            OxMessageBox.MsgBox3("删除成功!");
            IntoApply_Click();
        }
        /// <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);
        }
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            string       argument = Request.Form["__EVENTARGUMENT"];
            OracleAccess ora      = new OracleAccess();

            try
            {
                ora.ExecuteNonQuery("delete COMPUTER_ROOM_APPLY where COMPUTER_ROOM_APPLY_ID=" + argument);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            OxMessageBox.MsgBox3("删除成功!");
            int orgID = PrjPub.CurrentLoginUser.StationOrgID;

            grdEntity1Bind(orgID);
        }
 protected void btnPostBack_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(hidSubject.Value))
     {
         try
         {
             DeleteSubject(Convert.ToInt32(hidSubject.Value));
             DeleteSubjectResult(Convert.ToInt32(hfID.Value), Convert.ToInt32(hidSubject.Value));                  //删除该科目的结果
             //BindGridResult();
         }
         catch
         {
             OxMessageBox.MsgBox3("数据删除失败!");
         }
     }
     try
     {
         BindGridSubject();
         postStudent();
         BindGridResult();
     }
     catch (Exception)
     {
         OxMessageBox.MsgBox3("数据加载失败,请重试!");
     }
     if (hfSelectedIDs.Value != "")
     {
         OracleAccess access = new OracleAccess();
         string       sql    = string.Format("update zj_train_plan_employee set train_class_id=null  where train_plan_employee_id in ({0})",
                                             hfSelectedIDs.Value);
         access.ExecuteNonQuery(sql);
         BindGridStudent();
         DeleteResultByStuID(hfSelectedIDs.Value);
         BindGridResult();
         hfSelectedIDs.Value = "";
     }
 }
Exemple #7
0
        private void AddStudent()
        {
            List <string> lst = new List <string>();

            foreach (DataRow r in dtInfo.Rows)
            {
                string index = r["train_plan_employee_id"].ToString();
                if (usersDic[index] == true)
                {
                    lst.Add(index);
                }
            }
            foreach (GridViewRow gr in grdStudent.Rows)
            {
                System.Web.UI.HtmlControls.HtmlGenericControl spanID =
                    (System.Web.UI.HtmlControls.HtmlGenericControl)gr.Cells[0].FindControl("spanID");
                string   currentValue = spanID.InnerText;
                CheckBox currentCbx   = gr.Cells[0].FindControl("item") as CheckBox;
                if (currentCbx.Checked == true && !lst.Contains(currentValue))
                {
                    lst.Add(currentValue);
                }
            }
            hidID.Value = string.Join(",", lst.ToArray());
            try
            {
                string sql = string.Format("update zj_train_plan_employee set train_class_id={0} where train_plan_employee_id in ({1}) and train_plan_id={2}",
                                           Convert.ToInt32(Request.QueryString["classID"]), hidID.Value, Convert.ToInt32(hidPlanID.Value));
                OracleAccess oracleAccess = new OracleAccess();
                oracleAccess.ExecuteNonQuery(sql);
            }
            catch
            {
                OxMessageBox.MsgBox3("数据保存失败!");
            }
        }
        /// <summary>
        /// 修改的申请预订记录
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, ImageClickEventArgs e)
        {
            if (Request.QueryString["mode"] != null)
            {
                string state = Request.QueryString["mode"].ToString();
                if (isBlock())
                {
                    return;
                }
                int orgID                 = PrjPub.CurrentLoginUser.StationOrgID;
                int APPLY_ORG_ID          = int.Parse(this.DDLOrg.SelectedValue);
                int COMPUTER_ROOM_ID      = int.Parse(this.DDLComputerRoom.SelectedValue);
                int APPLY_COMPUTER_NUMBER = int.Parse(this.txtAPPLY_COMPUTER_NUMBER.Text.Trim().ToString());

                string strBegin = dateBeginTime.DateValue.ToString() + " " + ddlBeginHour.SelectedValue + ":00:00";
                string strEnd   = dateEndTime.DateValue.ToString() + " " + ddlEndHour.SelectedValue + ":00:00";

                try
                {
                    DateTime nowBegin = Convert.ToDateTime(strBegin);
                    DateTime nowEnd   = Convert.ToDateTime(strEnd);

                    if (nowEnd <= nowBegin)
                    {
                        this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('申请结束时间不能小于等于开始时间!')", true);
                        return;
                    }
                }
                catch (Exception ex)
                {
                    OxMessageBox.MsgBox3(ex.Message);
                    return;
                }

                OracleAccess ora = new OracleAccess();
                try
                {
                    if (state == "Insert")
                    {
                        //判断被申请微机教室是否被占用
                        //string strSql = "select * from Computer_Room_Apply a "
                        //         + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID "
                        //         + " where a.REPLY_STATUS=1 and a.Computer_Room_ID=" + DDLComputerRoom.SelectedValue
                        //         + " and ((a.Apply_Start_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                        //         + " and a.Apply_Start_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS'))"
                        //         + " or (a.Apply_End_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                        //         + " and a.Apply_End_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS')))";
                        //if(ora.RunSqlDataSet(strSql).Tables[0].Rows.Count > 0)
                        //{
                        //    this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('该微机教室已被本单位或其他单位占用,不能申请使用该微机教室!')", true);
                        //    return;
                        //}

                        DataSet ds = new DataSet();
                        ds = ora.RunSqlDataSet("select * from COMPUTER_ROOM_APPLY where ORG_ID=" + orgID + " and APPLY_ORG_ID=" + int.Parse(this.DDLOrg.SelectedValue) + " and COMPUTER_ROOM_ID=" + int.Parse(this.DDLComputerRoom.SelectedValue) + " and REPLY_STATUS=" + 0);
                        if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                        {
                            this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('当前单位已向该教室提出申请但未回复,不能重复申请!')", true);
                            return;
                        }
                        ora = new OracleAccess();
                        ora.ExecuteNonQuery(string.Format("insert into computer_room_apply(COMPUTER_ROOM_APPLY_ID,ORG_ID,"
                                                          + "apply_org_id,computer_room_id,apply_start_time,apply_end_time,apply_computer_number,REPLY_STATUS) "
                                                          + "  values({0},{1},{2},{3},to_date('{4}','yyyy-mm-dd hh24:mi:ss'),to_date('{5}','yyyy-mm-dd hh24:mi:ss'),{6},{7})", "COMPUTER_ROOM_APPLY_SEQ.NEXTVAL", orgID, APPLY_ORG_ID, COMPUTER_ROOM_ID, strBegin, strEnd, APPLY_COMPUTER_NUMBER, 0));
                    }
                    else if (state == "EditOne" || state == "EditTwo")
                    {
                        if (Request.QueryString["id"] != null)
                        {
                            string strSql = string.Empty;
                            int    _ComputerRoomApplyID = Convert.ToInt32(Request.QueryString["id"]);
                            int    REPLY_STATUS         = this.DDLREPLY_STATUS.SelectedIndex;
                            string REJECT_REASON        = this.txtREJECT_REASON.Text.Trim().ToString();
                            if (state == "EditOne")
                            {
                                //判断被申请微机教室是否被占用
                                //strSql = "select * from Computer_Room_Apply a "
                                //         + " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID "
                                //         + " where a.REPLY_STATUS=1 and a.Computer_Room_ID=" + DDLComputerRoom.SelectedValue
                                //         + " and ((a.Apply_Start_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                                //         + " and a.Apply_Start_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS'))"
                                //         + " or (a.Apply_End_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                                //         + " and a.Apply_End_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS')))";

                                //if (ora.RunSqlDataSet(strSql).Tables[0].Rows.Count > 0)
                                //{
                                //    this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('该微机教室已被本单位或其他单位占用,不能申请使用该微机教室!')", true);
                                //    return;
                                //}
                                ora.ExecuteNonQuery(string.Format("update computer_room_apply SET ORG_ID={0},APPLY_ORG_ID={1},COMPUTER_ROOM_ID={2},APPLY_START_TIME=to_date('{3}','yyyy-mm-dd hh24:mi:ss'),APPLY_END_TIME=to_date('{4}','yyyy-mm-dd hh24:mi:ss'),APPLY_COMPUTER_NUMBER={5},REPLY_STATUS={6},REJECT_REASON='{7}' where COMPUTER_ROOM_APPLY_ID={8}", orgID, APPLY_ORG_ID, COMPUTER_ROOM_ID, strBegin, strEnd, APPLY_COMPUTER_NUMBER, REPLY_STATUS, REJECT_REASON, _ComputerRoomApplyID));
                            }
                            else
                            {
                                //只需要修回复状态与回复原因
                                switch (REPLY_STATUS)
                                {
                                case 0:
                                    strSql = "update computer_room_apply SET REPLY_STATUS=0 where COMPUTER_ROOM_APPLY_ID=" + _ComputerRoomApplyID;
                                    break;

                                case 1:

                                    //strSql = "select * from Computer_Room_Apply a "
                                    //+ " inner join Computer_Room b on a.Computer_Room_ID=b.Computer_Room_ID "
                                    //+ " where a.REPLY_STATUS=1 and a.Computer_Room_ID=" + DDLComputerRoom.SelectedValue
                                    //+ " and ((a.Apply_Start_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                                    //+ " and a.Apply_Start_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS'))"
                                    //+ " or (a.Apply_End_Time >= to_date('" + strBegin + "','YYYY-MM-DD HH24:MI:SS')"
                                    //+ " and a.Apply_End_Time <= to_date('" + strEnd + "','YYYY-MM-DD HH24:MI:SS')))";
                                    //if (ora.RunSqlDataSet(strSql).Tables[0].Rows.Count > 0)
                                    //{
                                    //    this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('该微机教室已被本单位或其他单位占用,不能回复通过该微机教室的申请!')", true);
                                    //    return;
                                    //}

                                    strSql = "update computer_room_apply SET REPLY_STATUS=1 where COMPUTER_ROOM_APPLY_ID=" + _ComputerRoomApplyID;

                                    break;

                                case 2:
                                    if (string.IsNullOrEmpty(this.txtREJECT_REASON.Text.Trim().ToString()))
                                    {
                                        this.ClientScript.RegisterStartupScript(GetType(), "NO", "alert('请填写回复原因!')", true);
                                        this.txtREJECT_REASON.Focus();
                                        return;
                                    }
                                    strSql = "update computer_room_apply SET REPLY_STATUS=2,REJECT_REASON='" + this.txtREJECT_REASON.Text.Trim().ToString() + "' where COMPUTER_ROOM_APPLY_ID=" + _ComputerRoomApplyID;
                                    break;
                                }
                                ora.ExecuteNonQuery(strSql);

                                if (REPLY_STATUS == 1)
                                {
                                    ora.ExecuteNonQuery("update Computer_Room set Is_Use=1 where Computer_Room_ID=" + DDLComputerRoom.SelectedValue);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script>alert('" + ex.Message + "')</script>");
                    throw ex;
                }
                ClientScript.RegisterStartupScript(GetType(), "OK", "alert('保存成功!');top.returnValue='true';top.close();", true);
                //Response.Write("<script>top.returnValue='true';top.close();</script>");
            }
        }