Пример #1
0
    //[HideInInspector]
    //public bool usingIEcannotTap = false;

    public void whenOpenThisPanel()
    {
        currentHeroIndexInTeam = 0;

        currentEditType = editType.hero;
        goddessSelectSubPanel.gameObject.SetActive(false);
        goddess_pageController.ResetPage();

        GDEunitTeamData team = SDDataManager.Instance.getHeroTeamByTeamId(CurrentTeamId);

        teamNameText.text = team.teamName;
    }
Пример #2
0
    public void changeSelectSubPanel(editType oldType, editType newType)
    {
        if (newType == editType.goddess)
        {
            goddessSelectSubPanel.gameObject.SetActive(true);
            goddess_pageController.ItemsInit(SDConstants.ItemType.Goddess);
        }

        if (oldType == editType.goddess)
        {
            goddessSelectSubPanel.gameObject.SetActive(false);
            goddess_pageController.ResetPage();
        }
    }
Пример #3
0
 public void Btn_Change_Goddess()
 {
     currentEditType = editType.goddess;
 }
Пример #4
0
 /// <summary>
 /// 设置界面
 /// </summary>
 private void prepareForEdit(bool left, bool right, string rightBanner, bool save, bool addLine, bool delLine, bool delColumn, bool extraList, bool addPT, bool delPT, bool addColumn, editType et, string etName)
 {
     //界面设置
     splitContainer1.Panel1.Enabled = left;
     splitContainer1.Panel2.Enabled = right;
     lb_editpro_rightBanner.Text = rightBanner;
     tsb_editpro_save.Enabled = save;
     tsb_editpro_newline.Enabled = addLine;
     tsmi_editpro_DLine.Enabled = delLine;
     tsmi_editpro_DColumn.Enabled = delColumn;
     tscb_editpro_extraList.Visible = extraList;
     tsb_editpro_addPT.Visible = addPT;
     tsb_editpro_delPT.Visible = delPT;
     tsb_editpro_NColumn.Visible = addColumn;
     editTypeName = etName;
     //指定录入类型
     currentEditType = et;
     //事件清空
     this.save = null;
     NLine = null;
     DLine = null;
     NColumn = null;
     DColumn = null;
     AddPT = null;
     DelPT = null;
     CellDoubleClick = null;
     CellEndEdit = null;
     extraList_SelectedIndexChanged = null;
     //清空界面控件内容
     dgv_editpro.Columns.Clear();
     tscb_editpro_extraList.Items.Clear();
     tb_editpro_remarks.Text = "";
     //重置保存事件
     editedCells.Clear();
     setSaveState(true);//上面的设置有触发已编辑事件,这里重新改正
 }
Пример #5
0
        /// <summary>
        /// 其他测量类型的录入
        /// </summary>
        /// <param name="mtypeID">类型,用类型表的ID表达</param>
        /// <param name="nameOfOtherRem">表示其他备注的名称(常规的备注、工况以外的)</param>
        private void otherMTypeImport(string mtypeID, string nameOfOtherRem)
        {
            prepareForEdit(true, true, "本类别备注", true, true, true, true, false, false, false, true, editType.none, "");
            //下面再修改当前的录入类型
            switch (mtypeID)
            {
                case "1":
                    currentEditType = editType.pressD;
                    editTypeName = "基坑压顶水平位移";
                    break;
                case "2":
                    currentEditType = editType.subD;
                    editTypeName = "沉降位移";
                    break;
                case "3":
                    currentEditType = editType.ropeN;
                    editTypeName = "锚索内力";
                    break;
                case "4":
                    currentEditType = editType.supportN;
                    editTypeName = "支撑轴力";
                    break;
                case "5":
                    currentEditType = editType.waterD;
                    editTypeName = "地下水水位位移";
                    break;
            }
            #region 读入数据

            try
            {
                login.conn.Open();
                //首先读入总备注
                SqlCommand sc = new SqlCommand("select remark from fp_" + proID + "_mtype where ID='" + mtypeID + "'", login.conn);
                tb_editpro_remarks.Text = sc.ExecuteScalar().ToString();
                setSaveState(true);//读入备注的时候会把状态改为已编辑,这里调整保存状态

                //读入坐标列表
                //坐标列表,用于读出数据时改写pID值
                Dictionary<int, string> ptList = new Dictionary<int, string>();
                sc.CommandText = "select ID,pName from fp_" + proID + "_PT";
                SqlDataReader sdr = sc.ExecuteReader();
                while (sdr.Read())
                {
                    ptList.Add(sdr.GetInt32(0), sdr.GetString(1));
                }
                sdr.Close();

                //读入数据表
                SqlDataAdapter sda = new SqlDataAdapter("select * from fp_" + proID + "_" + mtypeID + " order by pID", login.conn);
                DataTable dt = new DataTable();
                sda.Fill(dt);
                dgv_editpro.Columns.Add("ID", "ID");
                dgv_editpro.Columns.Add("pID", "点位");
                dgv_editpro.Columns[0].DefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.Gray };
                dgv_editpro.Columns[1].DefaultCellStyle = new DataGridViewCellStyle() { BackColor = Color.Silver };
                dgv_editpro.Columns[0].ReadOnly = true;
                dgv_editpro.Columns[1].ReadOnly = true;
                //排序后的数据表
                DataTable sortedDt = null;

                //调整日期列
                if (dt.Columns.Count > 2)
                {
                    //读出日期表,用于日期排序
                    Dictionary<int, long> dateList = new Dictionary<int, long>();
                    sc.CommandText = "select ID,dateT from fp_" + proID + "_dateRemark";
                    sdr = sc.ExecuteReader();
                    while (sdr.Read())
                    {
                        dateList.Add(sdr.GetInt32(0), sdr.GetInt64(1));
                    }
                    sdr.Close();

                    //组出 列名-日期值 的字典
                    Dictionary<string, long> columnList = new Dictionary<string, long>();
                    for (int i = 2; i < dt.Columns.Count; i++)
                    {
                        columnList.Add(dt.Columns[i].ColumnName, dateList[Convert.ToInt32(dt.Columns[i].ColumnName.Substring(1))]);
                    }
                    //排序
                    var sortedcolumnList = columnList.OrderBy(n => n.Value);
                    //组建排序后的列名顺序列表
                    List<string> newColumnList = new List<string>();
                    newColumnList.Add("ID");
                    newColumnList.Add("pID");
                    foreach (var n in sortedcolumnList)
                    {
                        newColumnList.Add(n.Key);
                        //顺便把排序后的列添加到视图
                        dgv_editpro.Columns.Add(n.Key, DateTime.FromBinary(n.Value).ToString());
                    }
                    //根据新的列名顺序,组出新的数据表
                    sortedDt = dt.DefaultView.ToTable(false, newColumnList.ToArray());
                }

                //锁定数据表排序
                for (int i = 0; i < dgv_editpro.Columns.Count; i++)
                {
                    dgv_editpro.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
                }

                //写入数据
                DataTable finalDt = sortedDt == null ? dt : sortedDt;
                foreach (DataRow row in finalDt.Rows)
                {
                    dgv_editpro.Rows.Add(row.ItemArray);
                }

                //写入"备注,工况,其他备注"三行
                dgv_editpro.Rows.Add("备注", "-------");
                dgv_editpro.Rows.Add("工况", "-------");
                dgv_editpro.Rows.Add(nameOfOtherRem, "-------");
                sda = new SqlDataAdapter("select remark,condition,otherRem from fp_" + proID + "_dateRemark where mtypeID='" + mtypeID + "' order by dateT", login.conn);
                DataTable remarkInfo = new DataTable();
                sda.Fill(remarkInfo);
                if (remarkInfo.Rows.Count > 0)
                {
                    for (int i = 2; i < dgv_editpro.Columns.Count; i++)
                    {
                        for (int j = dgv_editpro.Rows.Count - 3; j < dgv_editpro.Rows.Count; j++)
                        {
                            dgv_editpro.Rows[j].Cells[i].Value = remarkInfo.Rows[i - 2].Field<string>(j - dgv_editpro.Rows.Count + 3);
                        }
                    }
                }

                //改写pID
                for (int i = 0; i < dgv_editpro.Rows.Count - 3; i++)
                {
                    setCell(i, 1, ptList[Convert.ToInt32(dgv_editpro.Rows[i].Cells[1].Value)]);
                }
            }
            catch (Exception exc)
            {
                throw exc;
            }
            finally
            {
                login.conn.Close();
            }
            #endregion

            #region 添加行
            NLine += (object o, EventArgs ea) =>
            {
                try
                {
                    //要求选择某个点位
                    AddPTDialog aptd = new AddPTDialog(proID);
                    if (aptd.ShowDialog() == DialogResult.OK)
                    {
                        if (aptd.pID != -1) //默认值是-1
                        {
                            login.conn.Open();
                            //插入到数据表
                            SqlCommand sc = new SqlCommand("insert into fp_" + proID + "_" + mtypeID + "(pID) values('" + aptd.pID.ToString() + "')", login.conn);
                            sc.ExecuteNonQuery();
                            login.conn.Close();
                            //刷新视图
                            otherMTypeImport(mtypeID, nameOfOtherRem);
                        }
                    }
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                finally { login.conn.Close(); }
            };
            #endregion

            #region 添加列
            NColumn += (object o, EventArgs ea) =>
            {
                try
                {
                    //选择某个日期
                    addDateDialog addia = new addDateDialog();
                    if (addia.ShowDialog() == DialogResult.OK)
                    {
                        if (addia.dateT != null)
                        {
                            //0 检查是否已经存在相同日期,若存在则抛出错误
                            login.conn.Open();
                            SqlCommand sc = new SqlCommand("select ID from fp_" + proID + "_dateRemark where dateT='" + addia.dateT.ToBinary().ToString() + "' and mtypeID='" + mtypeID + "'", login.conn);
                            if (sc.ExecuteScalar() != null)
                            {
                                throw new Exception("已存在相同的日期值");
                            }
                            //1 把日期插入dateRemark表并取回ID
                            sc.CommandText = "insert into fp_" + proID + "_dateRemark(dateT,mtypeID) values('" + addia.dateT.ToBinary().ToString() + "','" + mtypeID + "')";
                            sc.ExecuteNonQuery();
                            sc.CommandText = "select @@identity";
                            string currentID = sc.ExecuteScalar().ToString();
                            //2 插入到数据表
                            sc.CommandText = "alter table fp_" + proID + "_" + mtypeID + " add d" + currentID + " float";
                            sc.ExecuteNonQuery();
                            //3 刷新视图
                            login.conn.Close();
                            otherMTypeImport(mtypeID, nameOfOtherRem);//这里之前若不关闭连接会导致连接重复打开
                        }
                    }
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                finally
                {
                    login.conn.Close();//即使throw出来也能关闭conn
                }
            };
            #endregion

            #region 保存
            save += (object o, EventArgs ea) =>
            {
                try
                {
                    if (isSave) return;
                    login.conn.Open();
                    //首先保存总备注
                    SqlCommand sc = new SqlCommand("update fp_" + proID + "_mtype set remark='" + tb_editpro_remarks.Text + "' where ID='" + mtypeID + "'", login.conn);
                    sc.ExecuteNonQuery();
                    //保存日备注及其他信息
                    for (int i = 2; i < dgv_editpro.Columns.Count; i++)
                    {
                        object cell1 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 3].Cells[i].Value;
                        object cell2 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 2].Cells[i].Value;
                        object cell3 = dgv_editpro.Rows[dgv_editpro.Rows.Count - 1].Cells[i].Value;
                        if (cell1 == null) cell1 = "";
                        if (cell2 == null) cell2 = "";
                        if (cell3 == null) cell3 = "";
                        sc.CommandText = "update fp_" + proID + "_dateRemark set remark='" + cell1.ToString() + "',condition='" + cell2.ToString() + "',otherRem='" + cell3.ToString() + "' where dateT='" + DateTime.Parse(dgv_editpro.Columns[i].HeaderText).ToBinary().ToString() + "' and mtypeID='" + mtypeID + "'";
                        sc.ExecuteNonQuery();
                    }

                    //保存数据
                    for (int i = 0; i < dgv_editpro.Rows.Count - 3; i++)
                    {
                        sc.CommandText = "update fp_" + proID + "_" + mtypeID + " set ";
                        //组建命令
                        for (int j = 2; j < dgv_editpro.Columns.Count; j++)
                        {
                            if (j == 2)
                            {
                                sc.CommandText += dgv_editpro.Columns[j].Name + "='" + dgv_editpro.Rows[i].Cells[j].Value.ToString() + "'";
                                continue;
                            }
                            sc.CommandText += "," + dgv_editpro.Columns[j].Name + "='" + dgv_editpro.Rows[i].Cells[j].Value.ToString() + "'";
                        }
                        sc.CommandText += " where ID='" + dgv_editpro.Rows[i].Cells[0].Value.ToString() + "'";
                        sc.ExecuteNonQuery();
                    }
                    //刷新视图
                    //login.conn.Close();
                    //otherMTypeImport(mtypeID, nameOfOtherRem);

                    setSaveState(true);
                }
                catch (Exception exc)
                {
                    throw exc;
                }
                finally
                {
                    login.conn.Close();
                }
            };
            #endregion

            #region 删除行
            DLine += (object o, EventArgs ea) =>
            {
                try
                {
                    login.conn.Open();
                    SqlCommand sc = new SqlCommand();
                    sc.Connection = login.conn;

                    List<int> rowindices = new List<int>();//用于存储选中的行index
                    for (int i = 0; i < dgv_editpro.SelectedCells.Count; i++)
                    {
                        rowindices.Add(dgv_editpro.SelectedCells[i].RowIndex);
                    }
                    //清除多余的index
                    var tempIndices = rowindices.Distinct().Where(n => n < dgv_editpro.Rows.Count - 3);

                    //删除每一行
                    if (tempIndices.Count() > 0)
                    {
                        foreach (var n in tempIndices)
                        {
                            sc.CommandText = "delete from fp_" + proID + "_" + mtypeID + " where ID='" + dgv_editpro.Rows[n].Cells[0].Value.ToString() + "'";
                            sc.ExecuteNonQuery();
                            //从视图中移除该行
                            dgv_editpro.Rows.RemoveAt(n);
                        }
                        //刷新视图
                        //login.conn.Close();
                        //otherMTypeImport(mtypeID, nameOfOtherRem);
                    }
                }
                catch (Exception exc) { throw exc; }
                finally
                {
                    login.conn.Close();
                }
            };
            #endregion

            #region 删除列
            DColumn += (object o, EventArgs ea) =>
            {
                try
                {
                    login.conn.Open();
                    SqlCommand sc = new SqlCommand();
                    sc.Connection = login.conn;

                    List<int> columnsIndices = new List<int>();//用于存储选中的列index
                    for (int i = 0; i < dgv_editpro.SelectedCells.Count; i++)
                    {
                        columnsIndices.Add(dgv_editpro.SelectedCells[i].ColumnIndex);
                    }
                    //清除多余的index
                    var tempIndices = columnsIndices.Distinct().Where(n => n > 1);
                    //删除每一列
                    if (tempIndices.Count() > 0)
                    {
                        foreach (var n in tempIndices)
                        {
                            //从数据表中移除
                            sc.CommandText = "alter table fp_" + proID + "_" + mtypeID + " drop column " + dgv_editpro.Columns[n].Name;
                            sc.ExecuteNonQuery();
                            //从日期表中移除
                            sc.CommandText = "delete from fp_" + proID + "_dateRemark where ID='" + dgv_editpro.Columns[n].Name.Substring(1) + "'";
                            sc.ExecuteNonQuery();
                            //从视图中移除该列
                            dgv_editpro.Columns.Remove(dgv_editpro.Columns[n].Name);
                        }
                        //刷新视图
                        //login.conn.Close();
                        //otherMTypeImport(mtypeID, nameOfOtherRem);
                    }

                }
                catch (Exception exc) { throw exc; }
                finally
                {
                    login.conn.Close();
                }
            };
            #endregion
        }
Пример #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!User.Identity.IsAuthenticated || !User.IsInRole(UserRole.Editor.ToString()))
            {
                throw new Exception("You are not authorized to view this page.");
            }

            if (!IsPostBack)
            {
                bool   approved;
                string username;
                int    moduleID = -1;

                // If type is not specified in the query string, the
                // page was called incorrectly.  Exit immediately.
                if (Request["type"] == null || Request["username"] == null || Request["approved"] == null)
                {
                    throw new Exception("Page called incorrectly. Ln 97 " + Request.QueryString["type"]);
                }

                Email     msg;
                EmailType type;
                approved = Convert.ToBoolean(Request.QueryString["approved"]);
                username = Request.QueryString["username"];
                editType request = (editType)(Convert.ToInt32(Request.QueryString["type"]));

                switch (Convert.ToInt32(request))
                {
                case (int)editType.faculty:                         // a faculty request is being approved/rejected
                    if (approved)
                    {
                        // approved
                        type = EmailType.FacultyApproved;
                        CustomMsgValidator.Enabled = false;
                    }
                    else
                    {
                        // denied
                        type = EmailType.FacultyDenied;
                    }

                    msg = Emails.getEmail(type);
                    Emails.formatEmail(msg, username);
                    break;

                case (int)editType.submitter:                         // a submitter request is being approved/rejected
                    if (approved)
                    {
                        // approved
                        type = EmailType.SubmitterApproved;
                        CustomMsgValidator.Enabled = false;
                    }
                    else
                    {
                        // denied
                        type = EmailType.SubmitterDenied;
                    }

                    msg = Emails.getEmail(type);
                    Emails.formatEmail(msg, username);
                    break;

                case (int)editType.module:                         // a module submission is being approved/rejected
                    // The query string must include the
                    // moduleID or the page was called incorrectly.
                    if (Request.QueryString["moduleID"] == null)
                    {
                        throw new Exception("Page called incorrectly. Ln 142");
                    }

                    moduleID = Convert.ToInt32(Request.QueryString["moduleID"]);

                    if (approved)
                    {
                        // approved
                        type = EmailType.ModuleApproved;
                        CustomMsgValidator.Enabled = false;
                    }
                    else
                    {
                        // save by default
                        type = EmailType.ModuleDeniedSave;
                        DeleteCheck.Visible = true;
                    }

                    msg = Emails.getEmail(type);
                    if (msg == null)
                    {
                        throw new Exception("Message template not found. ");
                    }
                    Emails.formatEmail(msg, username, moduleID);

                    ModuleID = moduleID;
                    break;

                default:                         // Othwerwise the page was called incorrectly.
                    throw new Exception("Page called incorrectly.  Ln 171");
                }

                UserName = username;
                Message  = msg;
            }
        }