Ejemplo n.º 1
0
        public bool UpdateX()
        {
            SqlTransaction transaction;
            SqlConnection  connection = new SqlConnection(Atend.Control.ConnectionString.LocalcnString);
            SqlCommand     command    = new SqlCommand();

            command.Connection  = connection;
            command.CommandText = "B_EquipStatus_Update";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("iCode", Code));
            command.Parameters.Add(new SqlParameter("iName", Name));
            command.Parameters.Add(new SqlParameter("iACode", ACode));
            command.Parameters.Add(new SqlParameter("iIsDefault", IsDefault));

            command.Parameters.Add(new SqlParameter("iPricePercent", PricePercent));
            command.Parameters.Add(new SqlParameter("iExecutePricePercent", ExecutePricePercent));
            command.Parameters.Add(new SqlParameter("iWagePricePercent", WagePricePercent));

            try
            {
                connection.Open();
                transaction         = connection.BeginTransaction();
                command.Transaction = transaction;
                try
                {
                    command.ExecuteNonQuery();

                    for (int i = 0; i < arraySub.Count; i++)
                    {
                        Atend.Base.Base.BStatusWorkOrder status = new BStatusWorkOrder();
                        status.EquipStatusCode = Code;
                        status.WorkOrderCode   = Convert.ToInt32(arraySub[i].ToString());

                        if (!status.InsertX())
                        {
                            throw new Exception("Failed");
                        }
                    }

                    transaction.Commit();
                    connection.Close();
                    return(true);
                }
                catch (System.Exception ex)
                {
                    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                    ed.WriteMessage(string.Format(" ERROR BEquipStatus.Update(transaction) {0}\n", ex.Message));
                    transaction.Rollback();
                    connection.Close();
                    return(false);
                }
            }
            catch (System.Exception ex1)
            {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage(string.Format(" ERROR BEquipStatus.Update {0}\n", ex1.Message));
                connection.Close();
                return(false);
            }
        }
Ejemplo n.º 2
0
        public static BStatusWorkOrder SelectByCode(int Code)
        {
            SqlConnection  connection = new SqlConnection(Atend.Control.ConnectionString.LocalcnString);
            SqlDataAdapter adapter    = new SqlDataAdapter("B_Status_WorkOrder_Select", connection);

            adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            adapter.SelectCommand.Parameters.Add(new SqlParameter("iCode", Code));
            DataSet dsProduct = new DataSet();

            adapter.Fill(dsProduct);
            BStatusWorkOrder product = new BStatusWorkOrder();

            if (dsProduct.Tables[0].Rows.Count > 0)
            {
                product.Code            = Convert.ToInt32(dsProduct.Tables[0].Rows[0]["Code"].ToString());
                product.EquipStatusCode = Convert.ToInt32(dsProduct.Tables[0].Rows[0]["EquipStatusCode"].ToString());
                product.WorkOrderCode   = Convert.ToInt32(dsProduct.Tables[0].Rows[0]["WorkOrderCode"].ToString());
            }
            else
            {
                product.Code = -1;
            }
            return(product);
        }