Beispiel #1
0
        public string ShowOrderNumberByTid(int tid, string priority)
        {
            TicketsOrderEntity model = listOrder.Find(x => x.TicketID == tid);
            bool existOrderNumber    = model != null ? true : false;

            return(existOrderNumber == true?model.OrderNum.ToString() : priority);
        }
        /// <summary>
        /// Update a record
        /// </summary>
        public bool Update(TicketsOrderEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TicketsOrder set ");
            strSql.Append("ProjectID=@ProjectID,");
            strSql.Append("TicketID=@TicketID,");
            strSql.Append("OrderNum=@OrderNum");
            strSql.Append(" where TicketOrderID=@TicketOrderID ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "TicketOrderID", DbType.Int32, model.TicketOrderID);
                db.AddInParameter(dbCommand, "ProjectID", DbType.Int32, model.ProjectID);
                db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID);
                db.AddInParameter(dbCommand, "OrderNum", DbType.Int32, model.OrderNum);
                int rows = db.ExecuteNonQuery(dbCommand);

                if (rows > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Beispiel #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string[] tickets   = hidNewOrder.Value.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            int      projectID = 0;

            List <BrokenRuleMessage> listMsgs = new List <BrokenRuleMessage>();

            if (tickets.Length > 0)
            {
                if (RemoveTicketsOrder(out projectID))
                {
                    for (int i = 0; i < tickets.Length; i++)
                    {
                        int id = 0;
                        if (int.TryParse(tickets[i], out id) && id != 0)
                        {
                            TicketsOrderEntity model = TicketsOrderFactory.CreateTicketsOrderEntity(UserInfo.ID, ObjectFactory.GetInstance <ISystemDateTime>());
                            model.ProjectID = projectID;
                            model.TicketID  = id;
                            model.OrderNum  = i + 1;

                            ticketApp.InsertTicketsOrder(model);
                            RecordMsg(listMsgs, ticketApp.BrokenRuleMessages);
                        }
                    }
                    if (listMsgs.Count > 0)
                    {
                        ShowFailMessageToClient(listMsgs);
                    }
                    else
                    {
                        InitControls();
                        ShowSuccessMessageToClient(false, false);
                    }
                }
                else
                {
                    ShowFailMessageToClient();
                }
            }
        }
        /// <summary>
        /// Get an object entity
        /// </summary>
        public TicketsOrderEntity Get(int TicketID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from TicketsOrder ");
            strSql.Append(" where TicketID=@TicketID ");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                db.AddInParameter(dbCommand, "TicketID", DbType.Int32, TicketID);
                TicketsOrderEntity model = null;
                using (IDataReader dataReader = db.ExecuteReader(dbCommand))
                {
                    if (dataReader.Read())
                    {
                        model = TicketsOrderEntity.ReaderBind(dataReader);
                    }
                }
                return(model);
            }
        }
        /// <summary>
        /// Add a record
        /// </summary>
        public int Insert(TicketsOrderEntity model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TicketsOrder(");
            strSql.Append("ProjectID,TicketID,OrderNum)");

            strSql.Append(" values (");
            strSql.Append("@ProjectID,@TicketID,@OrderNum)");
            strSql.Append(";select ISNULL( SCOPE_IDENTITY(),0);");
            Database db = DatabaseFactory.CreateDatabase();

            using (DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString()))
            {
                try
                {
                    db.AddInParameter(dbCommand, "ProjectID", DbType.Int32, model.ProjectID);
                    db.AddInParameter(dbCommand, "TicketID", DbType.Int32, model.TicketID);
                    db.AddInParameter(dbCommand, "OrderNum", DbType.Int32, model.OrderNum);
                    int    result;
                    object obj = db.ExecuteScalar(dbCommand);
                    if (!int.TryParse(obj.ToString(), out result))
                    {
                        return(0);
                    }
                    return(result);
                }
                catch (Exception ex)
                {
                    WebLogAgent.Write(string.Format("[SQLText:{0},{1}Messages:\r\n{2}]",
                                                    strSql.ToString(),
                                                    base.FormatParameters(dbCommand.Parameters),
                                                    ex.Message));
                    return(0);
                }
            }
        }