Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rowStatus"></param>
        /// <param name="tblName"></param>
        /// <param name="columnName"></param>
        /// <param name="columnLabelName"></param>
        /// <param name="columnValue"></param>
        /// <param name="pkeysConds">"and sysProductClassId !='" + actRow.sysProductClassId.ToString() + "'"</param>
        /// <returns></returns>
        public static string Chk_ColumnValue(string rowStatus, string tblName, string columnName, string columnLabelName, string columnValue, string pkeysConds)
        {
            int count;

            if (rowStatus == "A")
            {
                count = Convert.ToInt32(SqlTool.GetOneDataValue("select count(*) from " + tblName + " where statusx='10' and " + columnName + "='" + columnValue + "'"));
                if (count > 0)
                {
                    return(string.Format("啟用中之{0}:【{1}】,<br>不可重複 ", columnLabelName, columnValue));
                }
            }
            else
            {
                count = Convert.ToInt32(SqlTool.GetOneDataValue("select count(*) from  " + tblName + " where statusx='10' and " + columnName + "='" + columnValue + "' " + pkeysConds));
                if (count > 0)
                {
                    return(string.Format("啟用中之{0}:【{1}】,<br>不可重複 ", columnLabelName, columnValue));
                }
            }

            return("");
        }
        public ActionResult DeleteSingle(string pks)
        {
            try
            {
                ZhWebClassV3.UserData userData = ZhWebClassV3.UserHelper.GetUserData();

                string[] pk             = pks.Split('/');
                object   pk_sysObjectId = pk[0];

                //查詢是否有使用者隸屬於該群組下
                strSql.Remove(0, strSql.Length);
                int count = Convert.ToInt32(SqlTool.GetOneDataValue("SELECT COUNT(*) FROM Q10_userVsObject WHERE sysObjectId='" + pk_sysObjectId + "'"));

                if (count == 0)
                {
                    #region 刪除 Server端的資料

                    strSql.Remove(0, strSql.Length);
                    strSql.Append("update Q10_Objects set statusx='30' where sysObjectId=@pk_sysObjectId");

                    SqlParameter[] param =
                    {
                        new SqlParameter("pk_sysObjectId", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, "", DataRowVersion.Proposed, pk_sysObjectId)
                    };

                    errStr = SqlTool.ExecuteNonQuery(strSql.ToString(), param);
                    if (errStr != "")
                    {
                        throw new Exception(errStr);
                    }

                    #region OperLog 刪除群組
                    if (Convert.ToBoolean(ZhConfig.GlobalSystemVar.tbl_OperLogFlag.Rows.Find(funcId)["isOperLogEnable"]) && errStr == "")
                    {
                        #region Gen tbl_operLog1 Data (Add/Modify)
                        DataTable tbl_operLog1 = userData.Get_tbl_operLogPart1();
                        tbl_operLog1.Columns.Add("sysObjectId", typeof(string));

                        DataRow operLogRow = tbl_operLog1.NewRow();
                        //operLogRow["rowId"] =0;
                        operLogRow["actSerial"]   = userData.actSerial;
                        operLogRow["sysUserId"]   = userData.sysUserId;
                        operLogRow["actStatus"]   = "D";
                        operLogRow["sysObjectId"] = pk_sysObjectId;

                        tbl_operLog1.Rows.Add(operLogRow);
                        #endregion

                        errStr = ZhWebClassSet.Log.LogSet.SaveOperLog(funcId, "S10_userGroup", tbl_operLog1);
                        if (errStr != "")
                        {
                            throw new Exception(errStr);
                        }
                    }
                    #endregion
                }
                else
                {
                    errStr = "Can't Delete";
                }
                #endregion

                if (errStr == "")
                {
                    return(Json("OK", JsonRequestBehavior.DenyGet));
                }
                else if (errStr == "Can't Delete")
                {
                    return(Json("Can't Delete", JsonRequestBehavior.DenyGet));
                }
                else
                {
                    return(Json(errStr, JsonRequestBehavior.DenyGet));
                }

                #endregion
            }
            catch (Exception ex) { return(Json(ex.Message, JsonRequestBehavior.DenyGet)); }
        }